]> git.rmz.io Git - dotfiles.git/blob - nvim/lua/plugins/lsp.lua
nvim: move settings from lsp to lang/python
[dotfiles.git] / nvim / lua / plugins / lsp.lua
1 return {
2 -- lspconfig
3 {
4 "neovim/nvim-lspconfig",
5 ---@class PluginLspOpts
6 --
7 init = function ()
8 local keys = require("lazyvim.plugins.lsp.keymaps").get()
9
10 -- TODO: setup a new mapping for this
11 -- { "gr", "<cmd>Telescope lsp_references<cr>", desc = "References" },
12 keys[#keys+1] = { "gr", false }
13 end,
14 opts = {
15 -- Automatically format on save
16 -- autoformat = false,
17 -- LSP Server Settings
18 ---@type lspconfig.options
19 servers = {
20 lua_ls = {
21 settings = {
22 Lua = {
23 diagnostics = {
24 disable = { "missing-fields", },
25 },
26 },
27 },
28 },
29 -- Add clangd extensions
30 -- https://github.com/p00f/clangd_extensions.nvim
31 },
32 -- you can do any additional lsp server setup here
33 -- return true if you don't want this server to be setup with lspconfig
34 ---@type table<string, fun(server:string, opts:_.lspconfig.options):boolean?>
35 setup = {
36 -- example to setup with typescript.nvim
37 -- tsserver = function(_, opts)
38 -- require("typescript").setup({ server = opts })
39 -- return true
40 -- end,
41 -- Specify * to use this function as a fallback for any server
42 -- ["*"] = function(server, opts) end,
43 },
44 },
45 },
46
47 -- cmdline tools and lsp servers
48 {
49
50 "williamboman/mason.nvim",
51 cmd = "Mason",
52 keys = { { "<leader>cm", "<cmd>Mason<cr>", desc = "Mason" } },
53 opts = {
54 ensure_installed = {
55 "stylua",
56 "shfmt",
57 -- "flake8",
58 },
59 },
60 ---@param opts MasonSettings | {ensure_installed: string[]}
61 config = function(_, opts)
62 require("mason").setup(opts)
63 local mr = require("mason-registry")
64 local function ensure_installed()
65 for _, tool in ipairs(opts.ensure_installed) do
66 local p = mr.get_package(tool)
67 if not p:is_installed() then
68 p:install()
69 end
70 end
71 end
72 if mr.refresh then
73 mr.refresh(ensure_installed)
74 else
75 ensure_installed()
76 end
77 end,
78 },
79 }