refactor + feat: replaced nvim-cmp w/ coq_nvim and refactored everything
This commit is contained in:
parent
f82cc2bc93
commit
7a906314d8
19 changed files with 435 additions and 311 deletions
|
|
@ -1,39 +1,156 @@
|
|||
return {
|
||||
-- Java
|
||||
-- For checksums: https://github.com/mfussenegger/nvim-jdtls/discussions/249#discussioncomment-3159367
|
||||
-- It's here first because it needs to have load before lspconfig apparently
|
||||
{
|
||||
"nvim-java/nvim-java",
|
||||
dependencies = {
|
||||
"neovim/nvim-lspconfig",
|
||||
},
|
||||
config = function()
|
||||
require("java").setup()
|
||||
require("lspconfig").jdtls.setup({})
|
||||
end
|
||||
},
|
||||
--
|
||||
-- What is this?
|
||||
-- Homepage: https://github.com/ms-jpq/coq_nvim
|
||||
|
||||
-- https://github.com/williamboman/mason.nvim?tab=readme-ov-file#configuration for more information
|
||||
-- https://github.com/williamboman/mason-lspconfig.nvim?tab=readme-ov-file#setup for more info
|
||||
-- Basically a completion plugin for neovim.
|
||||
-- More specifically it just helps with autocorrecting variables, by using
|
||||
-- text you have typed down or just by using libraries. LSP relies on this.
|
||||
|
||||
-- What is this?
|
||||
-- LSP = Language Server Protocol => A protocol that provides code-completion,
|
||||
-- syntax highlighting, marking of errors and more.
|
||||
|
||||
-- Homepages:
|
||||
-- mason = https://github.com/mason-org/mason.nvim
|
||||
-- mason-lspconfig = https://github.com/mason-org/mason-lspconfig.nvim
|
||||
-- nvim-lspconfig = https://github.com/neovim/nvim-lspconfig
|
||||
|
||||
-- Recommended MasonInstall list (mostly formatters):
|
||||
-- CMD: MasonInstall stylua prettier shfmt shellcheck
|
||||
|
||||
-- Homepage: https://github.com/windwp/nvim-ts-autotag
|
||||
-- What is it?
|
||||
-- Helps with automatically adding a ending tag
|
||||
-- NOTE: Test it out using HTML or JSON. (E.g <div>something</div>)
|
||||
|
||||
return {
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
"neovim/nvim-lspconfig",
|
||||
lazy = false,
|
||||
dependencies = {
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"neovim/nvim-lspconfig", -- https://github.com/neovim/nvim-lspconfig for more information
|
||||
},
|
||||
opts = function()
|
||||
require("mason").setup({
|
||||
registries = {
|
||||
"github:nvim-java/mason-registry",
|
||||
"github:mason-org/mason-registry"
|
||||
}
|
||||
{ "ms-jpq/coq_nvim", branch = "coq" },
|
||||
{ "ms-jpq/coq.artifacts", branch = "artifacts" },
|
||||
{ "ms-jpq/coq.thirdparty", branch = "3p" },
|
||||
},
|
||||
|
||||
init = function()
|
||||
local remap = vim.api.nvim_set_keymap
|
||||
local npairs = require("nvim-autopairs")
|
||||
|
||||
-- Prevents going to newline after an autocomplete.
|
||||
npairs.setup({ map_bs = false })
|
||||
|
||||
vim.g.coq_settings = {
|
||||
auto_start = "shut-up",
|
||||
keymap = {
|
||||
recommended = false,
|
||||
},
|
||||
completion = {
|
||||
skip_after = { "\t", "{" },
|
||||
},
|
||||
}
|
||||
|
||||
require("coq_3p")({
|
||||
{ src = "nvimlua", short_name = "nLUA" },
|
||||
{ src = "bc", short_name = "MATH", precision = 6 },
|
||||
{ src = "builtin/css" },
|
||||
{ src = "builtin/js" },
|
||||
{ src = "builtin/c" },
|
||||
{ src = "builtin/html" },
|
||||
{ src = "builtin/xml" },
|
||||
{ src = "repl", sh = "bash", unsafe = { "rm", "poweroff", "reboot", "mv" } },
|
||||
})
|
||||
|
||||
remap("i", "<esc>", [[pumvisible() ? "<c-e><esc>" : "<esc>"]], { expr = true, noremap = true })
|
||||
remap("i", "<c-c>", [[pumvisible() ? "<c-e><c-c>" : "<c-c>"]], { expr = true, noremap = true })
|
||||
remap("i", "<tab>", [[pumvisible() ? "<c-n>" : "<tab>"]], { expr = true, noremap = true })
|
||||
remap("i", "<s-tab>", [[pumvisible() ? "<c-p>" : "<bs>"]], { expr = true, noremap = true })
|
||||
|
||||
-- Prevents completion for everytime you press Enter
|
||||
remap(
|
||||
"i",
|
||||
"<CR>",
|
||||
[[pumvisible() ? (complete_info(['selected']).selected == -1 ? '<c-e><cr>' : '<c-y>') : '<cr>']],
|
||||
{ expr = true, noremap = false }
|
||||
)
|
||||
end,
|
||||
|
||||
config = function()
|
||||
local config = require("lspconfig")
|
||||
local coq = require("coq")
|
||||
|
||||
config.lua_ls.setup(coq.lsp_ensure_capabilities({
|
||||
settings = {
|
||||
Lua = {
|
||||
format = {
|
||||
enable = false,
|
||||
},
|
||||
diagnostics = {
|
||||
globals = { "vim" },
|
||||
},
|
||||
},
|
||||
},
|
||||
}))
|
||||
|
||||
config.pylsp.setup(coq.lsp_ensure_capabilities({}))
|
||||
|
||||
config.bashls.setup(coq.lsp_ensure_capabilities({}))
|
||||
|
||||
config.ts_ls.setup(coq.lsp_ensure_capabilities({
|
||||
init_options = { preferences = { disableSuggestions = false } },
|
||||
}))
|
||||
|
||||
config.eslint.setup(coq.lsp_ensure_capabilities({
|
||||
settings = { autoFixOnSave = true },
|
||||
}))
|
||||
|
||||
config.html.setup(coq.lsp_ensure_capabilities({}))
|
||||
|
||||
config.cssls.setup(coq.lsp_ensure_capabilities({
|
||||
settings = {
|
||||
css = {
|
||||
lint = {
|
||||
unknownAtRules = "ignore",
|
||||
},
|
||||
},
|
||||
scss = {
|
||||
lint = {
|
||||
unknownAtRules = "ignore",
|
||||
},
|
||||
},
|
||||
},
|
||||
}))
|
||||
|
||||
config.tailwindcss.setup(coq.lsp_ensure_capabilities({}))
|
||||
|
||||
config.clangd.setup(coq.lsp_ensure_capabilities({
|
||||
cmd = {
|
||||
"clangd",
|
||||
"--background-index",
|
||||
"--clang-tidy",
|
||||
"--log=verbose",
|
||||
"--query-driver=/usr/bin/c++",
|
||||
"--suggest-missing-includes",
|
||||
"--all-scopes-completion",
|
||||
"--completion-style=detailed",
|
||||
},
|
||||
init_options = {
|
||||
fallback_flags = { "-std=c++17" },
|
||||
},
|
||||
}))
|
||||
end,
|
||||
},
|
||||
|
||||
{
|
||||
"mason-org/mason.nvim",
|
||||
dependencies = {
|
||||
"mason-org/mason-lspconfig.nvim",
|
||||
},
|
||||
opts = function()
|
||||
require("mason").setup()
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = {
|
||||
-- Language Servers
|
||||
"lua_ls",
|
||||
"pylsp",
|
||||
"clangd",
|
||||
"bashls",
|
||||
"ts_ls",
|
||||
|
|
@ -41,75 +158,9 @@ return {
|
|||
"cssls",
|
||||
"html",
|
||||
"tailwindcss",
|
||||
-- Formatters
|
||||
"prettier",
|
||||
"stylua",
|
||||
"black"
|
||||
}
|
||||
})
|
||||
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
local config = require("lspconfig")
|
||||
|
||||
-- LSP Servers
|
||||
|
||||
config.lua_ls.setup {
|
||||
capabilities = capabilities
|
||||
}
|
||||
|
||||
-- FOR bashls
|
||||
-- Make sure to install 'shellcheck', :MasonInstall shellcheck
|
||||
-- Make sure to install 'shfmt', :MasonInstall shfmt
|
||||
|
||||
config.bashls.setup {
|
||||
capabilities = capabilities
|
||||
}
|
||||
|
||||
config.pylsp.setup {
|
||||
capabilities = capabilities
|
||||
}
|
||||
|
||||
config.clangd.setup {
|
||||
cmd = { "clangd", "--background-index", "--clang-tidy", "--log=verbose", "--query-driver=/usr/bin/c++", "--suggest-missing-includes", "--all-scopes-completion", "--completion-style=detailed" },
|
||||
init_options = {
|
||||
fallback_flags = { "-std=c++17" },
|
||||
"pylsp",
|
||||
},
|
||||
capabilities = capabilities
|
||||
}
|
||||
|
||||
config.ts_ls.setup {
|
||||
capabilities = capabilities,
|
||||
init_options = { preferences = { disableSuggestions = false } },
|
||||
}
|
||||
|
||||
config.eslint.setup {
|
||||
capabilities = capabilities,
|
||||
settings = { autoFixOnSave = true }
|
||||
}
|
||||
|
||||
config.html.setup {
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
||||
config.cssls.setup {
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
css = {
|
||||
lint = {
|
||||
unknownAtRules = "ignore"
|
||||
}
|
||||
},
|
||||
scss = {
|
||||
lint = {
|
||||
unknownAtRules = "ignore"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
config.tailwindcss.setup { }
|
||||
|
||||
end
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue