|
|
|
@ -1,20 +1,25 @@
|
|
|
|
|
-- todo allow config passed in
|
|
|
|
|
local lspconfig = nil
|
|
|
|
|
local log = require "navigator.util".log
|
|
|
|
|
|
|
|
|
|
if packer_plugins ~= nil then
|
|
|
|
|
if not packer_plugins["neovim/nvim-lspconfig"] or
|
|
|
|
|
not packer_plugins["neovim/nvim-lspconfig"].loaded then
|
|
|
|
|
if not packer_plugins["neovim/nvim-lspconfig"] or not packer_plugins["neovim/nvim-lspconfig"].loaded then
|
|
|
|
|
vim.cmd [[packadd nvim-lspconfig]]
|
|
|
|
|
end
|
|
|
|
|
if not packer_plugins["ray-x/guihua.lua"] or
|
|
|
|
|
not packer_plugins["guihua.lua"].loaded then
|
|
|
|
|
if not packer_plugins["ray-x/guihua.lua"] or not packer_plugins["guihua.lua"].loaded then
|
|
|
|
|
vim.cmd [[packadd guihua.lua]]
|
|
|
|
|
-- if lazyloading
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if package.loaded["lspconfig"] then lspconfig = require "lspconfig" end
|
|
|
|
|
if package.loaded["lspconfig"] then
|
|
|
|
|
lspconfig = require "lspconfig"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local highlight = require "navigator.lspclient.highlight"
|
|
|
|
|
if lspconfig == nil then error("loading lsp config") end
|
|
|
|
|
if lspconfig == nil then
|
|
|
|
|
error("loading lsp config")
|
|
|
|
|
end
|
|
|
|
|
local util = lspconfig.util
|
|
|
|
|
local config = require "navigator".config_values()
|
|
|
|
|
|
|
|
|
|
local cap = vim.lsp.protocol.make_client_capabilities()
|
|
|
|
@ -62,14 +67,16 @@ local golang_setup = {
|
|
|
|
|
},
|
|
|
|
|
root_dir = function(fname)
|
|
|
|
|
local util = require("lspconfig").util
|
|
|
|
|
return util.root_pattern("go.mod", ".git")(fname) or
|
|
|
|
|
util.path.dirname(fname)
|
|
|
|
|
return util.root_pattern("go.mod", ".git")(fname) or util.path.dirname(fname)
|
|
|
|
|
end
|
|
|
|
|
}
|
|
|
|
|
local clang_cfg = {
|
|
|
|
|
cmd = {
|
|
|
|
|
"clangd", "--background-index", "--suggest-missing-includes",
|
|
|
|
|
"--clang-tidy", "--header-insertion=iwyu"
|
|
|
|
|
"clangd",
|
|
|
|
|
"--background-index",
|
|
|
|
|
"--suggest-missing-includes",
|
|
|
|
|
"--clang-tidy",
|
|
|
|
|
"--header-insertion=iwyu"
|
|
|
|
|
},
|
|
|
|
|
on_attach = function(client)
|
|
|
|
|
client.resolved_capabilities.document_formatting = true
|
|
|
|
@ -78,6 +85,8 @@ local clang_cfg = {
|
|
|
|
|
}
|
|
|
|
|
local rust_cfg = {
|
|
|
|
|
settings = {
|
|
|
|
|
filetypes = {"rust"},
|
|
|
|
|
root_dir = util.root_pattern("Cargo.toml", "rust-project.json", ".git"),
|
|
|
|
|
["rust-analyzer"] = {
|
|
|
|
|
assist = {importMergeBehavior = "last", importPrefix = "by_self"},
|
|
|
|
|
cargo = {loadOutDirsFromCheck = true},
|
|
|
|
@ -122,8 +131,13 @@ local lua_cfg = {
|
|
|
|
|
enable = true,
|
|
|
|
|
-- Get the language server to recognize the `vim` global
|
|
|
|
|
globals = {
|
|
|
|
|
"vim", "describe", "it", "before_each", "after_each",
|
|
|
|
|
"teardown", "pending"
|
|
|
|
|
"vim",
|
|
|
|
|
"describe",
|
|
|
|
|
"it",
|
|
|
|
|
"before_each",
|
|
|
|
|
"after_each",
|
|
|
|
|
"teardown",
|
|
|
|
|
"pending"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
workspace = {
|
|
|
|
@ -138,12 +152,55 @@ local lua_cfg = {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local pyright_cfg = {
|
|
|
|
|
cmd = {"pyright-langserver", "--stdio"},
|
|
|
|
|
filetypes = {"python"},
|
|
|
|
|
settings = {
|
|
|
|
|
python = {
|
|
|
|
|
analysis = {
|
|
|
|
|
autoSearchPaths = true,
|
|
|
|
|
useLibraryCodeForTypes = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local rust_cfg = {
|
|
|
|
|
filetypes = {"rust"},
|
|
|
|
|
root_dir = util.root_pattern("Cargo.toml", "rust-project.json", ".git"),
|
|
|
|
|
message_level = vim.lsp.protocol.MessageType.error,
|
|
|
|
|
log_level = vim.lsp.protocol.MessageType.error,
|
|
|
|
|
on_attach = on_attach
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local servers = {
|
|
|
|
|
"gopls", "tsserver", "flow", "bashls", "dockerls", "pyls",
|
|
|
|
|
"jedi_language_server", "jdtls", "sumneko_lua", "vimls", "html", "jsonls",
|
|
|
|
|
"cssls", "yamlls", "clangd", "sqls", "denols", "dartls", "dotls",
|
|
|
|
|
"kotlin_language_server", "nimls", "phpactor", "r_language_server",
|
|
|
|
|
"rust_analyzer", "terraformls"
|
|
|
|
|
"gopls",
|
|
|
|
|
"tsserver",
|
|
|
|
|
"flow",
|
|
|
|
|
"bashls",
|
|
|
|
|
"dockerls",
|
|
|
|
|
"pyls",
|
|
|
|
|
"pyright",
|
|
|
|
|
"jedi_language_server",
|
|
|
|
|
"jdtls",
|
|
|
|
|
"sumneko_lua",
|
|
|
|
|
"vimls",
|
|
|
|
|
"html",
|
|
|
|
|
"jsonls",
|
|
|
|
|
"cssls",
|
|
|
|
|
"yamlls",
|
|
|
|
|
"clangd",
|
|
|
|
|
"sqls",
|
|
|
|
|
"denols",
|
|
|
|
|
"dartls",
|
|
|
|
|
"dotls",
|
|
|
|
|
"kotlin_language_server",
|
|
|
|
|
"nimls",
|
|
|
|
|
"phpactor",
|
|
|
|
|
"r_language_server",
|
|
|
|
|
"rust_analyzer",
|
|
|
|
|
"terraformls"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local function setup(user_opts)
|
|
|
|
@ -164,23 +221,25 @@ local function setup(user_opts)
|
|
|
|
|
local ft = vim.bo.filetype
|
|
|
|
|
local should_load = false
|
|
|
|
|
for _, value in ipairs(lspft) do
|
|
|
|
|
if ft == value then should_load = true end
|
|
|
|
|
if ft == value then
|
|
|
|
|
should_load = true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if not should_load then
|
|
|
|
|
goto continue
|
|
|
|
|
end
|
|
|
|
|
if not should_load then goto continue end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
lspconfig[lspclient].setup {
|
|
|
|
|
message_level = vim.lsp.protocol.MessageType.error,
|
|
|
|
|
log_level = vim.lsp.protocol.MessageType.error,
|
|
|
|
|
on_attach = on_attach
|
|
|
|
|
}
|
|
|
|
|
::continue::
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
lspconfig.rust_analyzer.setup(rust_cfg)
|
|
|
|
|
lspconfig.gopls.setup(golang_setup)
|
|
|
|
|
lspconfig.sqls.setup(sqls_cfg)
|
|
|
|
|
lspconfig.sumneko_lua.setup(lua_cfg)
|
|
|
|
|
lspconfig.clangd.setup(clang_cfg)
|
|
|
|
|
lspconfig.rust_analyzer.setup(rust_cfg)
|
|
|
|
|
lspconfig.pyright.setup(pyright_cfg)
|
|
|
|
|
|
|
|
|
|
log("setup all clients finished")
|
|
|
|
|
end
|
|
|
|
|
return {setup = setup, cap = cap}
|
|
|
|
|