mirror of
https://github.com/LunarVim/LunarVim.git
synced 2025-08-31 07:09:23 +02:00
[feature] Move common parts of language server setup to lsp/init (#1355)
* moving common parts of language server setup to lsp/init * fix formatting
This commit is contained in:
parent
85fe093efb
commit
2bcbed1499
2 changed files with 13 additions and 152 deletions
|
@ -115,10 +115,6 @@ lvim = {
|
|||
}
|
||||
|
||||
local schemas = nil
|
||||
local lsp = require "lsp"
|
||||
local common_on_attach = lsp.common_on_attach
|
||||
local common_capabilities = lsp.common_capabilities()
|
||||
local common_on_init = lsp.common_on_init
|
||||
local status_ok, jsonls_settings = pcall(require, "nlspsettings.jsonls")
|
||||
if status_ok then
|
||||
schemas = jsonls_settings.get_default_schemas()
|
||||
|
@ -151,9 +147,6 @@ lvim.lang = {
|
|||
provider = "beancount",
|
||||
setup = {
|
||||
cmd = { "beancount-langserver" },
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -180,9 +173,6 @@ lvim.lang = {
|
|||
"--clang-tidy",
|
||||
"--clang-tidy-checks=-*,llvm-*,clang-analyzer-*",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -209,9 +199,6 @@ lvim.lang = {
|
|||
"--clang-tidy",
|
||||
"--clang-tidy-checks=-*,llvm-*,clang-analyzer-*",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -227,9 +214,6 @@ lvim.lang = {
|
|||
provider = "crystalline",
|
||||
setup = {
|
||||
cmd = { "crystalline" },
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -254,9 +238,6 @@ lvim.lang = {
|
|||
"--hostPID",
|
||||
tostring(vim.fn.getpid()),
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -274,9 +255,6 @@ lvim.lang = {
|
|||
cmd = {
|
||||
DATA_PATH .. "/lspinstall/cmake/venv/bin/cmake-language-server",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -289,9 +267,6 @@ lvim.lang = {
|
|||
cmd = {
|
||||
DATA_PATH .. "/lspinstall/clojure/clojure-lsp",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -315,9 +290,6 @@ lvim.lang = {
|
|||
DATA_PATH .. "/lspinstall/css/vscode-css/css-language-features/server/dist/node/cssServerMain.js",
|
||||
"--stdio",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -341,9 +313,6 @@ lvim.lang = {
|
|||
DATA_PATH .. "/lspinstall/css/vscode-css/css-language-features/server/dist/node/cssServerMain.js",
|
||||
"--stdio",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -359,9 +328,6 @@ lvim.lang = {
|
|||
provider = "serve_d",
|
||||
setup = {
|
||||
cmd = { "serve-d" },
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -381,9 +347,6 @@ lvim.lang = {
|
|||
"/usr/lib/dart/bin/snapshots/analysis_server.dart.snapshot",
|
||||
"--lsp",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -397,9 +360,6 @@ lvim.lang = {
|
|||
DATA_PATH .. "/lspinstall/dockerfile/node_modules/.bin/docker-langserver",
|
||||
"--stdio",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -417,9 +377,6 @@ lvim.lang = {
|
|||
cmd = {
|
||||
DATA_PATH .. "/lspinstall/elixir/elixir-ls/language_server.sh",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -437,8 +394,6 @@ lvim.lang = {
|
|||
cmd = {
|
||||
DATA_PATH .. "/lspinstall/elm/node_modules/.bin/elm-language-server",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
-- init_options = {
|
||||
-- elmAnalyseTrigger = "change",
|
||||
-- elmFormatPath = DATA_PATH .. "/lspinstall/elm/node_modules/.bin/elm-format",
|
||||
|
@ -462,9 +417,6 @@ lvim.lang = {
|
|||
cmd = {
|
||||
"erlang_ls",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -479,11 +431,7 @@ lvim.lang = {
|
|||
linters = {},
|
||||
lsp = {
|
||||
provider = "",
|
||||
setup = {
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
setup = {},
|
||||
},
|
||||
},
|
||||
fortran = {
|
||||
|
@ -495,9 +443,6 @@ lvim.lang = {
|
|||
cmd = {
|
||||
DATA_PATH .. "/lspinstall/fortran/venv/bin/fortls",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -523,9 +468,6 @@ lvim.lang = {
|
|||
cmd = {
|
||||
DATA_PATH .. "/lspinstall/go/gopls",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -541,9 +483,6 @@ lvim.lang = {
|
|||
"-m",
|
||||
"stream",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -554,9 +493,6 @@ lvim.lang = {
|
|||
provider = "hls",
|
||||
setup = {
|
||||
cmd = { DATA_PATH .. "/lspinstall/haskell/hls" },
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -580,9 +516,6 @@ lvim.lang = {
|
|||
DATA_PATH .. "/lspinstall/html/vscode-html/html-language-features/server/dist/node/htmlServerMain.js",
|
||||
"--stdio",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -602,9 +535,6 @@ lvim.lang = {
|
|||
provider = "jdtls",
|
||||
setup = {
|
||||
cmd = { DATA_PATH .. "/lspinstall/java/jdtls.sh" },
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -632,9 +562,6 @@ lvim.lang = {
|
|||
DATA_PATH .. "/lspinstall/json/vscode-json/json-language-features/server/dist/node/jsonServerMain.js",
|
||||
"--stdio",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
settings = {
|
||||
json = {
|
||||
schemas = schemas,
|
||||
|
@ -669,9 +596,6 @@ lvim.lang = {
|
|||
-- vim.fn.expand "~/.config/nvim/lua/lsp/julia/run.jl",
|
||||
CONFIG_PATH .. "/utils/julia/run.jl",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -684,8 +608,6 @@ lvim.lang = {
|
|||
cmd = {
|
||||
DATA_PATH .. "/lspinstall/kotlin/server/bin/kotlin-language-server",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
root_dir = function(fname)
|
||||
local util = require "lspconfig/util"
|
||||
|
||||
|
@ -725,9 +647,6 @@ lvim.lang = {
|
|||
"-E",
|
||||
DATA_PATH .. "/lspinstall/lua/main.lua",
|
||||
},
|
||||
capabilities = common_capabilities,
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
|
@ -811,8 +730,6 @@ lvim.lang = {
|
|||
DATA_PATH .. "/lspinstall/php/node_modules/.bin/intelephense",
|
||||
"--stdio",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
filetypes = { "php", "phtml" },
|
||||
settings = {
|
||||
intelephense = {
|
||||
|
@ -834,9 +751,6 @@ lvim.lang = {
|
|||
DATA_PATH .. "/lspinstall/puppet/puppet-editor-services/puppet-languageserver",
|
||||
"--stdio",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -865,9 +779,6 @@ lvim.lang = {
|
|||
DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server",
|
||||
"--stdio",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -895,9 +806,6 @@ lvim.lang = {
|
|||
DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server",
|
||||
"--stdio",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -920,9 +828,6 @@ lvim.lang = {
|
|||
DATA_PATH .. "/lspinstall/python/node_modules/.bin/pyright-langserver",
|
||||
"--stdio",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -945,9 +850,6 @@ lvim.lang = {
|
|||
"-e",
|
||||
"languageserver::run()",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -966,9 +868,6 @@ lvim.lang = {
|
|||
DATA_PATH .. "/lspinstall/ruby/solargraph/solargraph",
|
||||
"stdio",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
filetypes = { "ruby" },
|
||||
init_options = {
|
||||
formatting = true,
|
||||
|
@ -999,9 +898,6 @@ lvim.lang = {
|
|||
cmd = {
|
||||
DATA_PATH .. "/lspinstall/rust/rust-analyzer",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1015,11 +911,7 @@ lvim.lang = {
|
|||
linters = { "" },
|
||||
lsp = {
|
||||
provider = "metals",
|
||||
setup = {
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
setup = {},
|
||||
},
|
||||
},
|
||||
sh = {
|
||||
|
@ -1037,9 +929,6 @@ lvim.lang = {
|
|||
DATA_PATH .. "/lspinstall/bash/node_modules/.bin/bash-language-server",
|
||||
"start",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1053,9 +942,6 @@ lvim.lang = {
|
|||
DATA_PATH .. "/lspinstall/svelte/node_modules/.bin/svelteserver",
|
||||
"--stdio",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1074,9 +960,6 @@ lvim.lang = {
|
|||
"xcrun",
|
||||
"sourcekit-lsp",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1107,9 +990,6 @@ lvim.lang = {
|
|||
DATA_PATH .. "/lspinstall/terraform/terraform-ls",
|
||||
"serve",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1120,9 +1000,6 @@ lvim.lang = {
|
|||
provider = "texlab",
|
||||
setup = {
|
||||
cmd = { DATA_PATH .. "/lspinstall/latex/texlab" },
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1150,9 +1027,6 @@ lvim.lang = {
|
|||
DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server",
|
||||
"--stdio",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1181,9 +1055,6 @@ lvim.lang = {
|
|||
DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server",
|
||||
"--stdio",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1197,9 +1068,6 @@ lvim.lang = {
|
|||
DATA_PATH .. "/lspinstall/vim/node_modules/.bin/vim-language-server",
|
||||
"--stdio",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1225,9 +1093,6 @@ lvim.lang = {
|
|||
cmd = {
|
||||
DATA_PATH .. "/lspinstall/vue/node_modules/.bin/vls",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1250,9 +1115,6 @@ lvim.lang = {
|
|||
DATA_PATH .. "/lspinstall/yaml/node_modules/.bin/yaml-language-server",
|
||||
"--stdio",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1265,9 +1127,6 @@ lvim.lang = {
|
|||
cmd = {
|
||||
"zls",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1282,9 +1141,6 @@ lvim.lang = {
|
|||
"localhost",
|
||||
"6008",
|
||||
},
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1295,9 +1151,6 @@ lvim.lang = {
|
|||
provider = "powershell_es",
|
||||
setup = {
|
||||
bundle_path = "",
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1320,9 +1173,6 @@ lvim.lang = {
|
|||
local util = require "lspconfig/util"
|
||||
return util.root_pattern ".git"(fname) or vim.fn.getcwd()
|
||||
end,
|
||||
on_attach = common_on_attach,
|
||||
on_init = common_on_init,
|
||||
capabilities = common_capabilities,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -138,6 +138,17 @@ function M.setup(lang)
|
|||
|
||||
if lsp.provider ~= nil and lsp.provider ~= "" then
|
||||
local lspconfig = require "lspconfig"
|
||||
|
||||
if not lsp.setup.on_attach then
|
||||
lsp.setup.on_attach = M.common_on_attach
|
||||
end
|
||||
if not lsp.setup.on_init then
|
||||
lsp.setup.on_init = M.common_on_init
|
||||
end
|
||||
if not lsp.setup.capabilities then
|
||||
lsp.setup.capabilities = M.common_capabilities()
|
||||
end
|
||||
|
||||
lspconfig[lsp.provider].setup(lsp.setup)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue