Skip to content

Commit 6bd5e5a

Browse files
committed
refactor: lsp setup
1 parent a01b2fe commit 6bd5e5a

5 files changed

Lines changed: 90 additions & 96 deletions

File tree

.config/nvim/lsp/eslint.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
return {
2+
cmd = { "vscode-eslint-languageserver", "--stdio" }
3+
}

.config/nvim/lsp/gopls.lua

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
return {
2+
-- cmd = { vim.fn.getenv("HOME") .. "/go/bin/gopls" },
3+
settings = {
4+
gopls = {
5+
hints = {
6+
assignVariableTypes = true,
7+
compositeLiteralFields = true,
8+
compositeLiteralTypes = true,
9+
constantValues = true,
10+
functionTypeParameters = true,
11+
parameterNames = true,
12+
rangeVariableTypes = true
13+
},
14+
gofumpt = true,
15+
staticcheck = true,
16+
usePlaceholders = false,
17+
semanticTokens = true,
18+
directoryFilters = { "-.git", "-.vscode", "-.idea", "-.vscode-test", "-node_modules" },
19+
codelenses = {
20+
gc_details = true,
21+
generate = true,
22+
regenerate_cgo = true,
23+
run_govulncheck = true,
24+
test = true,
25+
tidy = true,
26+
upgrade_dependency = true,
27+
vendor = true,
28+
},
29+
-- https://github.com/golang/tools/blob/master/gopls/doc/analyzers.md
30+
analyses = {
31+
staticcheck = true,
32+
shadow = true,
33+
},
34+
},
35+
},
36+
}

.config/nvim/lsp/lua_ls.lua

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
return {
2+
on_init = function(client)
3+
local path = client.workspace_folders[1].name
4+
if vim.uv.fs_stat(path .. '/.luarc.json') or vim.uv.fs_stat(path .. '/.luarc.jsonc') then
5+
return
6+
end
7+
client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
8+
workspace = {
9+
checkThirdParty = false,
10+
library = {
11+
vim.env.VIMRUNTIME
12+
}
13+
-- This pulls in a lot or more files
14+
-- library = vim.api.nvim_get_runtime_file("", true)
15+
}
16+
})
17+
end,
18+
settings = {
19+
Lua = {
20+
runtime = {
21+
version = 'LuaJIT'
22+
},
23+
}
24+
}
25+
}

.config/nvim/lsp/yamlls.lua

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
return {
2+
settings = {
3+
yaml = {
4+
schemas = {
5+
["https://json.schemastore.org/github-workflow.json"] = "/.github/workflows/*",
6+
["/home/dozy/projects/ika/config/schema.json"] = "ika.yaml",
7+
-- ["/home/dozy/projects/ika/config/schema.json"] = "ika.example.yaml",
8+
},
9+
format = {
10+
enable = true,
11+
bracketSpacing = true
12+
},
13+
schemaStore = {
14+
enable = true
15+
}
16+
},
17+
},
18+
}

.config/nvim/lua/plugins/lsp.lua

Lines changed: 8 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ return {
3030
-----------------
3131
-- LSP Servers --
3232
-----------------
33-
-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
33+
-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md
3434

35-
-- LSPs with default configurations
36-
local default_lsps = {
35+
-- LSPs
36+
local enabled_lsps = {
3737
"clangd",
3838
"pyright",
3939
"dockerls",
@@ -51,103 +51,15 @@ return {
5151
"nim_langserver",
5252
"terraformls",
5353
"erlangls",
54+
"eslint",
55+
"gopls",
56+
"yamlls",
57+
"lua_ls",
5458
}
5559

56-
for _, name in ipairs(default_lsps) do
60+
for _, name in ipairs(enabled_lsps) do
5761
vim.lsp.enable(name)
5862
end
59-
60-
-- LSPs with custom configurations
61-
vim.lsp.config('eslint', {
62-
cmd = { "vscode-eslint-languageserver", "--stdio" }
63-
})
64-
vim.lsp.enable('eslint')
65-
66-
vim.lsp.config('gopls', {
67-
-- cmd = { vim.fn.getenv("HOME") .. "/go/bin/gopls" },
68-
settings = {
69-
gopls = {
70-
hints = {
71-
assignVariableTypes = true,
72-
compositeLiteralFields = true,
73-
compositeLiteralTypes = true,
74-
constantValues = true,
75-
functionTypeParameters = true,
76-
parameterNames = true,
77-
rangeVariableTypes = true
78-
},
79-
gofumpt = true,
80-
staticcheck = true,
81-
usePlaceholders = false,
82-
semanticTokens = true,
83-
directoryFilters = { "-.git", "-.vscode", "-.idea", "-.vscode-test", "-node_modules" },
84-
codelenses = {
85-
gc_details = true,
86-
generate = true,
87-
regenerate_cgo = true,
88-
run_govulncheck = true,
89-
test = true,
90-
tidy = true,
91-
upgrade_dependency = true,
92-
vendor = true,
93-
},
94-
-- https://github.com/golang/tools/blob/master/gopls/doc/analyzers.md
95-
analyses = {
96-
staticcheck = true,
97-
shadow = true,
98-
},
99-
},
100-
},
101-
})
102-
vim.lsp.enable('gopls')
103-
104-
-- https://github.com/redhat-developer/yaml-language-server
105-
vim.lsp.config('yamlls', {
106-
settings = {
107-
yaml = {
108-
schemas = {
109-
["https://json.schemastore.org/github-workflow.json"] = "/.github/workflows/*",
110-
["/home/dozy/projects/ika/config/schema.json"] = "ika.yaml",
111-
-- ["/home/dozy/projects/ika/config/schema.json"] = "ika.example.yaml",
112-
},
113-
format = {
114-
enable = true,
115-
bracketSpacing = true
116-
},
117-
schemaStore = {
118-
enable = true
119-
}
120-
},
121-
},
122-
})
123-
vim.lsp.enable('yamlls')
124-
125-
vim.lsp.config('lua_ls', {
126-
on_init = function(client)
127-
local path = client.workspace_folders[1].name
128-
if vim.uv.fs_stat(path .. '/.luarc.json') or vim.uv.fs_stat(path .. '/.luarc.jsonc') then
129-
return
130-
end
131-
client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
132-
workspace = {
133-
checkThirdParty = false,
134-
library = {
135-
vim.env.VIMRUNTIME
136-
}
137-
-- This pulls in a lot or more files
138-
-- library = vim.api.nvim_get_runtime_file("", true)
139-
}
140-
})
141-
end,
142-
settings = {
143-
Lua = {
144-
runtime = {
145-
version = 'LuaJIT'
146-
},
147-
}
148-
}
149-
})
150-
vim.lsp.enable('lua_ls')
15163
end,
15264
cond = function()
15365
return not vim.g.vscode

0 commit comments

Comments
 (0)