lsp.lua
4786 bytes
1return {
2 {
3 "williamboman/mason.nvim",
4 dependencies = { "williamboman/mason-lspconfig.nvim" },
5 config = function()
6 require("mason").setup()
7 require("mason-lspconfig").setup({
8 automatic_installation = true,
9 ensure_installed = {},
10 })
11 end,
12 },
13 {
14 "neovim/nvim-lspconfig",
15 dependencies = { "saghen/blink.cmp" },
16 config = function(_, _)
17 local prettier = {
18 formatCommand = 'prettierd "${INPUT}"',
19 formatStdin = true,
20 env = {
21 string.format(
22 "PRETTIERD_DEFAULT_CONFIG=%s",
23 vim.fn.expand("~/.config/nvim/utils/linter-config/.prettierrc.json")
24 ),
25 },
26 }
27 local efm_languages = {
28 markdown = { prettier },
29 }
30 local servers = {
31 golangci_lint_ls = {},
32 gopls = {
33 settings = {
34 gopls = {
35 gofumpt = false,
36 staticcheck = true,
37 analyses = {
38 ST1000 = false,
39 },
40 hints = {
41 assignVariableTypes = false,
42 compositeLiteralFields = false,
43 compositeLiteralTypes = false,
44 constantValues = false,
45 functionTypeParameters = false,
46 parameterNames = false,
47 rangeVariableTypes = false,
48 },
49 },
50 },
51 },
52 templ = {},
53 rust_analyzer = {
54 settings = {
55 ["rust-analyzer"] = {
56 check = {
57 command = "clippy",
58 },
59 diagnostics = {
60 enable = true,
61 },
62 cargo = {
63 allFeatures = true,
64 },
65 imports = {
66 granularity = {
67 group = "module",
68 },
69 prefix = "self",
70 },
71 procMacro = {
72 enable = true,
73 },
74 },
75 },
76 },
77 basedpyright = {},
78 ruff = {},
79 efm = {
80 cmd = { "/home/pavle/.local/share/nvim/mason/bin/efm-langserver" },
81 init_options = { documentFormatting = true },
82 filetypes = vim.tbl_keys(efm_languages),
83 settings = {
84 rootMarkers = { ".prettierrc", ".prettierignore", ".git/" },
85 lintDebounce = 100,
86 logLevel = 5,
87 logFile = "/home/pavle/.local/state/nvim/efm.log",
88 languages = efm_languages,
89 },
90 single_file_support = true,
91 },
92 eslint = {},
93 ts_ls = {},
94 prismals = {},
95 graphql = {},
96 -- gleam = {},
97 buf_ls = {},
98 lua_ls = {},
99 terraformls = {
100 cmd = {
101 "/home/pavle/dev/terraform-ls/terraform-ls",
102 "serve",
103 },
104 },
105 jsonls = {},
106 yamlls = {
107 settings = {
108 yaml = {
109 format = {
110 enable = false,
111 },
112 },
113 },
114 },
115 jsonnet_ls = {},
116 bashls = {},
117 sourcekit = {},
118 -- zls = {},
119 }
120
121 for server, config in pairs(servers) do
122 config.capabilities = require("blink.cmp").get_lsp_capabilities(config.capabilities)
123 vim.lsp.config(server, config)
124 vim.lsp.enable(server)
125 end
126 end,
127 },
128 {
129 "saghen/blink.cmp",
130 version = "1.*",
131 dependencies = {
132 {
133 "folke/lazydev.nvim",
134 ft = "lua",
135 opts = {
136 library = { "LazyVim" },
137 },
138 },
139 },
140 ---@module 'blink.cmp'
141 ---@type blink.cmp.Config
142 opts = {
143 fuzzy = { implementation = "prefer_rust_with_warning" },
144 sources = {
145 default = { "lazydev", "lsp", "path" },
146 providers = {
147 lazydev = {
148 name = "LazyDev",
149 module = "lazydev.integrations.blink",
150 score_offset = 100,
151 },
152 },
153 },
154 keymap = {
155 preset = "default",
156 ["<CR>"] = { "select_and_accept", "fallback" },
157 },
158 completion = {
159 keyword = {
160 -- 'prefix' will fuzzy match on the text before the cursor
161 -- 'full' will fuzzy match on the text before _and_ after the cursor
162 range = "full",
163 },
164 documentation = {
165 auto_show = true,
166 },
167 },
168 signature = { enabled = true },
169 },
170 },
171 {
172 "ray-x/go.nvim",
173 dependencies = {
174 "ray-x/guihua.lua",
175 "neovim/nvim-lspconfig",
176 "nvim-treesitter/nvim-treesitter",
177 },
178 config = function()
179 require("go").setup()
180 -- go.nvim incorrectly uses buf_request instead of buf_notify for
181 -- workspace/didChangeWatchedFiles, causing errors on go.mod save
182 vim.api.nvim_create_augroup("gomod_save", { clear = true })
183 end,
184 event = { "CmdlineEnter" },
185 ft = { "go", "gomod" },
186 build = ':lua require("go.install").update_all_sync()',
187 },
188 {
189 "stevearc/conform.nvim",
190 config = function()
191 require("conform").setup({
192 format_on_save = {
193 timeout_ms = 2000,
194 lsp_format = "fallback",
195 },
196 formatters_by_ft = {
197 lua = { "stylua" },
198 markdown = { "markdownlint" },
199 terraform = { "tflint" },
200 json = { "jsonlint", "prettierd" },
201 javascript = { "prettierd" },
202 typescript = { "prettierd" },
203 go = { "golangci-lint" },
204 templ = { "templ" },
205 html = { "htmlbeautifier", "htmlhint" },
206 tmpl = { "htmlbeautifier", "htmlhint" },
207 yaml = {},
208 },
209 })
210 end,
211 },
212}