Parent directory

lsp.lua

4694 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				jsonls = {},
101				yamlls = {
102					settings = {
103						yaml = {
104							format = {
105								enable = false,
106							},
107						},
108					},
109				},
110				jsonnet_ls = {},
111				bashls = {},
112				sourcekit = {},
113				-- zls = {},
114			}
115
116			for server, config in pairs(servers) do
117				config.capabilities = require("blink.cmp").get_lsp_capabilities(config.capabilities)
118				vim.lsp.config(server, config)
119				vim.lsp.enable(server)
120			end
121		end,
122	},
123	{
124		"saghen/blink.cmp",
125		version = "1.*",
126		dependencies = {
127			{
128				"folke/lazydev.nvim",
129				ft = "lua",
130				opts = {
131					library = { "LazyVim" },
132				},
133			},
134		},
135		---@module 'blink.cmp'
136		---@type blink.cmp.Config
137		opts = {
138			fuzzy = { implementation = "prefer_rust_with_warning" },
139			sources = {
140				default = { "lazydev", "lsp", "path" },
141				providers = {
142					lazydev = {
143						name = "LazyDev",
144						module = "lazydev.integrations.blink",
145						score_offset = 100,
146					},
147				},
148			},
149			keymap = {
150				preset = "default",
151				["<CR>"] = { "select_and_accept", "fallback" },
152			},
153			completion = {
154				keyword = {
155					-- 'prefix' will fuzzy match on the text before the cursor
156					-- 'full' will fuzzy match on the text before _and_ after the cursor
157					range = "full",
158				},
159				documentation = {
160					auto_show = true,
161				},
162			},
163			signature = { enabled = true },
164		},
165	},
166	{
167		"ray-x/go.nvim",
168		dependencies = {
169			"ray-x/guihua.lua",
170			"neovim/nvim-lspconfig",
171			"nvim-treesitter/nvim-treesitter",
172		},
173		config = function()
174			require("go").setup()
175			-- go.nvim incorrectly uses buf_request instead of buf_notify for
176			-- workspace/didChangeWatchedFiles, causing errors on go.mod save
177			vim.api.nvim_create_augroup("gomod_save", { clear = true })
178		end,
179		event = { "CmdlineEnter" },
180		ft = { "go", "gomod" },
181		build = ':lua require("go.install").update_all_sync()',
182	},
183	{
184		"stevearc/conform.nvim",
185		config = function()
186			require("conform").setup({
187				format_on_save = {
188					timeout_ms = 2000,
189					lsp_format = "fallback",
190				},
191				formatters_by_ft = {
192					lua = { "stylua" },
193					markdown = { "markdownlint" },
194					terraform = { "tflint" },
195					json = { "jsonlint", "prettierd" },
196					javascript = { "prettierd" },
197					typescript = { "prettierd" },
198					go = { "golangci-lint" },
199					templ = { "templ" },
200					html = { "htmlbeautifier", "htmlhint" },
201					tmpl = { "htmlbeautifier", "htmlhint" },
202					yaml = {},
203				},
204			})
205		end,
206	},
207}