feat: neovim lsp
This commit is contained in:
parent
45563277d5
commit
c8ef495a63
22 changed files with 177 additions and 86 deletions
|
|
@ -1,4 +1,6 @@
|
|||
local util = require("lspconfig.util")
|
||||
local async = require("lspconfig.async")
|
||||
local mod_cache = nil
|
||||
|
||||
require("lspconfig").lua_ls.setup({
|
||||
on_init = function(client)
|
||||
|
|
@ -90,6 +92,42 @@ return {
|
|||
cmd = { "typescript-language-server", "--stdio" },
|
||||
filetypes = { "vue", "ts", "tsx" },
|
||||
},
|
||||
clangd = {
|
||||
cmd = { "clangd" },
|
||||
root_markers = { ".git", ".clangd", "compile_commands.json" },
|
||||
filetypes = { "cpp", "c" },
|
||||
capabilities = {
|
||||
textDocument = {
|
||||
semanticTokens = {
|
||||
multilineTokenSupport = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
gopls = {
|
||||
cmd = { "gopls" },
|
||||
filetypes = { "go", "gomod", "gowork", "gotmpl" },
|
||||
root_dir = function(fname)
|
||||
-- see: https://github.com/neovim/nvim-lspconfig/issues/804
|
||||
if not mod_cache then
|
||||
local result = async.run_command({ "go", "env", "GOMODCACHE" })
|
||||
|
||||
if result and result[1] then
|
||||
mod_cache = vim.trim(result[1])
|
||||
else
|
||||
mod_cache = vim.fn.system("go env GOMODCACHE")
|
||||
end
|
||||
end
|
||||
if mod_cache and fname:sub(1, #mod_cache) == mod_cache then
|
||||
local clients = util.get_lsp_clients({ name = "gopls" })
|
||||
if #clients > 0 then
|
||||
return clients[#clients].config.root_dir
|
||||
end
|
||||
end
|
||||
return util.root_pattern("go.work", "go.mod", ".git")(fname)
|
||||
end,
|
||||
single_file_support = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
setup = {},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue