166 lines
4.2 KiB
Lua
166 lines
4.2 KiB
Lua
-- What is this?
|
|
-- Homepage: https://github.com/ms-jpq/coq_nvim
|
|
|
|
-- 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 {
|
|
{
|
|
"neovim/nvim-lspconfig",
|
|
lazy = false,
|
|
dependencies = {
|
|
{ "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",
|
|
"clangd",
|
|
"bashls",
|
|
"ts_ls",
|
|
"eslint",
|
|
"cssls",
|
|
"html",
|
|
"tailwindcss",
|
|
"pylsp",
|
|
},
|
|
})
|
|
end,
|
|
},
|
|
}
|