Skip to content

Commit ac681e0

Browse files
committed
chore(lsp-config): update config files and clean up
1 parent 518fc29 commit ac681e0

21 files changed

+54
-329
lines changed

lua/modules/configs/completion/servers/ansiblels.lua

Lines changed: 0 additions & 28 deletions
This file was deleted.

lua/modules/configs/completion/servers/azure_pipelines_ls.lua

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,4 @@
11
-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/configs/bashls.lua
22
return {
3-
cmd = { "bash-language-server", "start" },
4-
settings = {
5-
bashIde = {
6-
-- Glob pattern for finding and parsing shell script files in the workspace.
7-
-- Used by the background analysis features across files.
8-
9-
-- Prevent recursive scanning which will cause issues when opening a file
10-
-- directly in the home directory (e.g. ~/foo.sh).
11-
--
12-
-- Default upstream pattern is "**/*@(.sh|.inc|.bash|.command)".
13-
globPattern = vim.env.GLOB_PATTERN or "*@(.sh|.inc|.bash|.command)",
14-
},
15-
},
16-
filetypes = { "bash", "sh" },
17-
root_dir = function(fname)
18-
return vim.fs.dirname(vim.fs.find(".git", { path = fname, upward = true })[1])
19-
end,
203
single_file_support = true,
214
}

lua/modules/configs/completion/servers/dartls.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@
22
return {
33
cmd = { "dart", "language-server", "--protocol=lsp" },
44
filetypes = { "dart" },
5+
root_markers = { "pubspec.yaml" },
56
init_options = {
67
closingLabels = true,
78
flutterOutline = true,
89
onlyAnalyzeProjectsWithOpenFiles = true,
910
outline = true,
1011
suggestFromUnimportedLibraries = true,
1112
},
13+
settings = {
14+
dart = {
15+
completeFunctionCalls = true,
16+
showTodos = true,
17+
},
18+
},
1219
}

lua/modules/configs/completion/servers/docker_compose_language_service.lua

Lines changed: 0 additions & 8 deletions
This file was deleted.

lua/modules/configs/completion/servers/dockerls.lua

Lines changed: 0 additions & 9 deletions
This file was deleted.

lua/modules/configs/completion/servers/emmet_ls.lua

Lines changed: 0 additions & 26 deletions
This file was deleted.

lua/modules/configs/completion/servers/gh_actions_ls.lua

Lines changed: 0 additions & 25 deletions
This file was deleted.

lua/modules/configs/completion/servers/gitlab_ci_ls.lua

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 37 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,40 @@
11
-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/configs/gopls.lua
2+
local mod_cache = nil
3+
4+
---@param fname string
5+
---@return string?
6+
local function get_root(fname)
7+
if mod_cache and fname:sub(1, #mod_cache) == mod_cache then
8+
local clients = vim.lsp.get_clients({ name = "gopls" })
9+
if #clients > 0 then
10+
return clients[#clients].config.root_dir
11+
end
12+
end
13+
return vim.fs.root(fname, "go.work") or vim.fs.root(fname, "go.mod") or vim.fs.root(fname, ".git")
14+
end
15+
216
return {
3-
cmd = { "gopls", "-remote.debug=:0", "-remote=auto" },
4-
filetypes = { "go", "gomod", "gosum", "gotmpl", "gohtmltmpl", "gotexttmpl" },
5-
flags = { allow_incremental_sync = true, debounce_text_changes = 500 },
6-
capabilities = {
7-
textDocument = {
8-
completion = {
9-
contextSupport = true,
10-
dynamicRegistration = true,
11-
completionItem = {
12-
commitCharactersSupport = true,
13-
deprecatedSupport = true,
14-
preselectSupport = true,
15-
insertReplaceSupport = true,
16-
labelDetailsSupport = true,
17-
snippetSupport = true,
18-
documentationFormat = { "markdown", "plaintext" },
19-
resolveSupport = {
20-
properties = {
21-
"documentation",
22-
"details",
23-
"additionalTextEdits",
24-
},
25-
},
26-
},
27-
},
28-
},
29-
},
30-
settings = {
31-
gopls = {
32-
staticcheck = true,
33-
semanticTokens = true,
34-
usePlaceholders = true,
35-
completeUnimported = true,
36-
symbolMatcher = "Fuzzy",
37-
buildFlags = { "-tags", "integration" },
38-
semanticTokenTypes = { string = false },
39-
codelenses = {
40-
generate = true,
41-
gc_details = true,
42-
test = true,
43-
tidy = true,
44-
vendor = true,
45-
regenerate_cgo = true,
46-
upgrade_dependency = true,
47-
},
48-
},
49-
},
17+
cmd = { "gopls" },
18+
filetypes = { "go", "gomod", "gowork", "gotmpl" },
19+
root_dir = function(bufnr, on_dir)
20+
local fname = vim.api.nvim_buf_get_name(bufnr)
21+
-- see: https://github.com/neovim/nvim-lspconfig/issues/804
22+
if mod_cache then
23+
on_dir(get_root(fname))
24+
return
25+
end
26+
local cmd = { "go", "env", "GOMODCACHE" }
27+
vim.system(cmd, { text = true }, function(output)
28+
if output.code == 0 then
29+
if output.stdout then
30+
mod_cache = vim.trim(output.stdout)
31+
end
32+
on_dir(get_root(fname))
33+
else
34+
vim.schedule(function()
35+
vim.notify(("[gopls] cmd failed with code %d: %s\n%s"):format(output.code, cmd, output.stderr))
36+
end)
37+
end
38+
end)
39+
end,
5040
}

0 commit comments

Comments
 (0)