summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2022-10-14 18:51:54 -0500
committerToby Vincent <tobyv13@gmail.com>2022-10-14 18:51:54 -0500
commitea69362bfd34d4a4216207c4274e0c31e8e3147e (patch)
treed469f7151a6e5e35065328653124be1afe313d8a
parent6acbce39243f6ef9fd7dba56aa732280fb63c350 (diff)
feat(nvim): move lsp configs into seperate module
-rw-r--r--nvim/.config/nvim/lua/tobyvin/lsp/init.lua118
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins.lua106
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/cmp.lua3
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/lspconfig.lua100
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/neodev.lua22
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/rust-tools.lua45
6 files changed, 180 insertions, 214 deletions
diff --git a/nvim/.config/nvim/lua/tobyvin/lsp/init.lua b/nvim/.config/nvim/lua/tobyvin/lsp/init.lua
index b1e46bd..513b2c0 100644
--- a/nvim/.config/nvim/lua/tobyvin/lsp/init.lua
+++ b/nvim/.config/nvim/lua/tobyvin/lsp/init.lua
@@ -73,20 +73,116 @@ lsp.on_attach = function(client, bufnr)
vim.api.nvim_exec_autocmds("User", { pattern = "LspAttach", data = { client_id = client.id } })
end
-lsp.config = function(config)
- local capabilities = vim.lsp.protocol.make_client_capabilities()
- capabilities.textDocument.completion.completionItem.snippetSupport = true
- capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities)
-
- return vim.tbl_deep_extend("keep", config or {}, {
- capabilities = capabilities,
- on_attach = lsp.on_attach,
- })
-end
+lsp.default_config = {
+ on_attach = lsp.on_attach,
+ capabilities = vim.lsp.protocol.make_client_capabilities(),
+}
+
+lsp.configs = {
+ bashls = {},
+ taplo = {},
+ yamlls = {},
+ tsserver = {},
+ pylsp = {
+ settings = {
+ pylsp = {
+ plugins = {
+ autopep8 = {
+ enabled = false,
+ },
+ yapf = {
+ enabled = false,
+ },
+ pylint = {
+ enabled = true,
+ },
+ },
+ },
+ },
+ },
+ cssls = {},
+ cssmodules_ls = {},
+ stylelint_lsp = {},
+ ccls = {},
+ gopls = {
+ cmd = { "gopls", "serve" },
+ settings = {
+ gopls = {
+ analyses = {
+ unusedparams = true,
+ },
+ staticcheck = true,
+ },
+ },
+ },
+ ["rust-analyzer"] = {
+ standalone = true,
+ settings = {
+ ["rust-analyzer"] = {
+ cargo = {
+ allFeatures = true,
+ },
+ checkOnSave = {
+ command = "clippy",
+ },
+ },
+ },
+ },
+ sumneko_lua = {
+ settings = {
+ Lua = {
+ completion = {
+ callSnippet = "Replace",
+ },
+ diagnostics = {
+ globals = { "vim", "packer_plugins" },
+ },
+ format = {
+ enable = false,
+ },
+ telemetry = {
+ enable = false,
+ },
+ },
+ },
+ },
+ texlab = {
+ settings = {
+ texlab = {
+ build = {
+ args = {
+ "-pdf",
+ "-interaction=nonstopmode",
+ "-synctex=1",
+ string.format("-auxdir=%s/aux", vim.fn.getcwd()),
+ string.format("-outdir=%s/out", vim.fn.getcwd()),
+ "-emulate-aux-dir",
+ "%f",
+ },
+ onSave = true,
+ },
+ chktex = {
+ onEdit = true,
+ onOpenAndSave = true,
+ },
+ auxDirectory = string.format("%s/aux", vim.fn.getcwd()),
+ latexindent = {
+ ["local"] = string.format("%s/latexindent/indentconfig.yaml", vim.env.XDG_CONFIG_HOME),
+ modifyLineBreaks = true,
+ },
+ },
+ },
+ on_attach = function(client, bufnr)
+ vim.g.tex_flavor = "latex"
+ vim.opt.spell = true
+ lsp.on_attach(client, bufnr)
+ end,
+ },
+}
lsp.setup = function()
lsp.handlers.setup()
- require("tobyvin.lsp.diagnostics").setup()
+ lsp.diagnostics.setup()
end
return lsp
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins.lua b/nvim/.config/nvim/lua/tobyvin/plugins.lua
index bacdae2..e161de8 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins.lua
@@ -122,63 +122,6 @@ M.plugins = function(use)
})
use({
- "williamboman/mason-lspconfig.nvim",
- after = "mason.nvim",
- requires = {
- "williamboman/mason.nvim",
- },
- config = function()
- require("tobyvin.plugins.mason-lspconfig").setup()
- end,
- })
-
- use({
- "neovim/nvim-lspconfig",
- after = "mason-lspconfig.nvim",
- requires = {
- "ray-x/lsp_signature.nvim",
- "SmiteshP/nvim-navic",
- "barreiroleo/ltex-extra.nvim",
- },
- config = function()
- require("tobyvin.plugins.lspconfig").setup()
- end,
- })
-
- use({
- "folke/neodev.nvim",
- after = "nvim-lspconfig",
- requires = {
- "neovim/nvim-lspconfig",
- },
- config = function()
- require("tobyvin.plugins.neodev").setup()
- end,
- })
-
- use({
- "simrat39/rust-tools.nvim",
- after = "nvim-lspconfig",
- requires = {
- "neovim/nvim-lspconfig",
- },
- config = function()
- require("tobyvin.plugins.rust-tools").setup()
- end,
- })
-
- use({
- "brymer-meneses/grammar-guard.nvim",
- after = "nvim-lspconfig",
- requires = {
- "neovim/nvim-lspconfig",
- },
- config = function()
- require("grammar-guard").init()
- end,
- })
-
- use({
"hrsh7th/nvim-cmp",
requires = {
"hrsh7th/cmp-nvim-lsp",
@@ -230,6 +173,55 @@ M.plugins = function(use)
})
use({
+ "williamboman/mason-lspconfig.nvim",
+ after = "mason.nvim",
+ requires = {
+ "williamboman/mason.nvim",
+ },
+ config = function()
+ require("tobyvin.plugins.mason-lspconfig").setup()
+ end,
+ })
+
+ use({
+ "folke/neodev.nvim",
+ config = function()
+ require("tobyvin.plugins.neodev").setup()
+ end,
+ })
+
+ use({
+ "simrat39/rust-tools.nvim",
+ requires = {
+ "neovim/nvim-lspconfig",
+ },
+ config = function()
+ require("tobyvin.plugins.rust-tools").setup()
+ end,
+ })
+
+ use({
+ "neovim/nvim-lspconfig",
+ after = {
+ "mason-lspconfig.nvim",
+ "neodev.nvim",
+ "rust-tools.nvim",
+ "cmp-nvim-lsp",
+ },
+ requires = {
+ "folke/neodev.nvim",
+ "simrat39/rust-tools.nvim",
+ "hrsh7th/cmp-nvim-lsp",
+ "ray-x/lsp_signature.nvim",
+ "SmiteshP/nvim-navic",
+ "barreiroleo/ltex-extra.nvim",
+ },
+ config = function()
+ require("tobyvin.plugins.lspconfig").setup()
+ end,
+ })
+
+ use({
"kevinhwang91/nvim-bqf",
requires = {
"nvim-treesitter/nvim-treesitter",
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/cmp.lua b/nvim/.config/nvim/lua/tobyvin/plugins/cmp.lua
index 88b546f..2c2fe18 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/cmp.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/cmp.lua
@@ -1,3 +1,4 @@
+local lsp = require("tobyvin.lsp")
local M = {}
M.enabled = function()
@@ -21,6 +22,8 @@ M.setup = function()
return
end
+ lsp.default_config.capabilities = require("cmp_nvim_lsp").update_capabilities(lsp.default_config.capabilities)
+
cmp.setup({
enabled = M.enabled,
snippet = {
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/lspconfig.lua b/nvim/.config/nvim/lua/tobyvin/plugins/lspconfig.lua
index 1b9a373..3d62229 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/lspconfig.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/lspconfig.lua
@@ -1,5 +1,4 @@
local lsp = require("tobyvin.lsp")
-local utils = require("tobyvin.utils")
local M = {}
M.setup = function()
@@ -9,100 +8,13 @@ M.setup = function()
return
end
- lspconfig.bashls.setup(lsp.config())
+ lspconfig.util.default_config = vim.tbl_extend("force", lspconfig.util.default_config, lsp.default_config)
- lspconfig.taplo.setup(lsp.config())
-
- lspconfig.yamlls.setup(lsp.config({
- settings = {
- yaml = {
- editor = {
- formatOnType = true,
- },
- format = {
- enable = true,
- },
- },
- redhat = {
- telemetry = {
- enabled = false,
- },
- },
- },
- }))
-
- lspconfig.tsserver.setup(lsp.config())
-
- lspconfig.pylsp.setup(lsp.config({
- settings = {
- pylsp = {
- plugins = {
- autopep8 = {
- enabled = false,
- },
- yapf = {
- enabled = false,
- },
- pylint = {
- enabled = true,
- },
- },
- },
- },
- }))
-
- lspconfig.cssls.setup(lsp.config())
-
- lspconfig.cssmodules_ls.setup(lsp.config())
-
- lspconfig.stylelint_lsp.setup(lsp.config())
-
- lspconfig.ccls.setup(lsp.config())
-
- lspconfig.gopls.setup(lsp.config({
- cmd = { "gopls", "serve" },
- settings = {
- gopls = {
- analyses = {
- unusedparams = true,
- },
- staticcheck = true,
- },
- },
- }))
-
- lspconfig.texlab.setup(lsp.config({
- settings = {
- texlab = {
- build = {
- args = {
- "-pdf",
- "-interaction=nonstopmode",
- "-synctex=1",
- string.format("-auxdir=%s/aux", vim.fn.getcwd()),
- string.format("-outdir=%s/out", vim.fn.getcwd()),
- "-emulate-aux-dir",
- "%f",
- },
- onSave = true,
- },
- chktex = {
- onEdit = true,
- onOpenAndSave = true,
- },
- auxDirectory = string.format("%s/aux", vim.fn.getcwd()),
- latexindent = {
- ["local"] = string.format("%s/latexindent/indentconfig.yaml", vim.env.XDG_CONFIG_HOME),
- modifyLineBreaks = true,
- },
- },
- },
- on_attach = function(client, bufnr)
- vim.g.tex_flavor = "latex"
- vim.opt.spell = true
- lsp.on_attach(client, bufnr)
- end,
- }))
+ for name, config in pairs(lsp.configs) do
+ if name ~= "rust-analyzer" then
+ lspconfig[name].setup(config)
+ end
+ end
require("lsp_signature").setup({
bind = true,
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/neodev.lua b/nvim/.config/nvim/lua/tobyvin/plugins/neodev.lua
index 5bb3fce..a2f0477 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/neodev.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/neodev.lua
@@ -24,28 +24,6 @@ M.setup = function()
end
end,
})
-
- local lsp = require("tobyvin.lsp")
- local lspconfig = require("lspconfig")
-
- lspconfig.sumneko_lua.setup(lsp.config({
- settings = {
- Lua = {
- completion = {
- callSnippet = "Replace",
- },
- diagnostics = {
- globals = { "vim", "packer_plugins" },
- },
- format = {
- enable = false,
- },
- telemetry = {
- enable = false,
- },
- },
- },
- }))
end
return M
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/rust-tools.lua b/nvim/.config/nvim/lua/tobyvin/plugins/rust-tools.lua
index 000ce23..b8a4456 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/rust-tools.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/rust-tools.lua
@@ -12,39 +12,24 @@ M.setup = function()
return
end
- rust_tools.setup({
- server = lsp.config({
- standalone = true,
- settings = {
- ["rust-analyzer"] = {
- cargo = {
- allFeatures = true,
- },
- checkOnSave = {
- command = "clippy",
- },
- },
- },
- on_attach = function(client, bufnr)
- lsp.on_attach(client, bufnr)
+ lsp.configs["rust-analyzer"].on_attach = function(client, bufnr)
+ lsp.on_attach(client, bufnr)
+
+ local runnables = rust_tools.runnables.runnables
+ local debuggables = rust_tools.debuggables.debuggables
+ local open_cargo_toml = rust_tools.open_cargo_toml.open_cargo_toml
+ local external_docs = rust_tools.external_docs.open_external_docs
- local runnables = rust_tools.runnables.runnables
- local debuggables = rust_tools.debuggables.debuggables
- local open_cargo_toml = rust_tools.open_cargo_toml.open_cargo_toml
- local external_docs = rust_tools.external_docs.open_external_docs
- local run_cargo_cmd = function()
- utils.job.cmd("cargo")
- end
+ utils.keymap.group("n", "<leader>r", { desc = "Run" })
+ vim.keymap.set("n", "<leader>rr", runnables, { desc = "Runnables", buffer = bufnr })
+ vim.keymap.set("n", "<leader>rd", debuggables, { desc = "Debug", buffer = bufnr })
+ vim.keymap.set("n", "<leader>ro", open_cargo_toml, { desc = "Open Cargo.toml", buffer = bufnr })
- utils.keymap.group("n", "<leader>r", { desc = "Run" })
- vim.keymap.set("n", "<leader>rr", runnables, { desc = "Runnables", buffer = bufnr })
- vim.keymap.set("n", "<leader>rd", debuggables, { desc = "Debug", buffer = bufnr })
- vim.keymap.set("n", "<leader>ro", open_cargo_toml, { desc = "Open Cargo.toml", buffer = bufnr })
- vim.keymap.set("n", "<leader>rc", run_cargo_cmd, { desc = "Command", buffer = bufnr })
+ utils.documentation.register("rust", external_docs)
+ end
- utils.documentation.register("rust", external_docs)
- end,
- }),
+ rust_tools.setup({
+ server = lsp.configs["rust-analyzer"],
dap = {
adapter = require("rust-tools.dap").get_codelldb_adapter(M.codelldb, M.liblldb),
},