]> git.rmz.io Git - dotfiles.git/blob - nvim/lua/plugins/lsp.lua
nvim: import full lspconfig spec from lazyvim
[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 diagnostics = {
16 underline = true,
17 update_in_insert = false,
18 virtual_text = {
19 spacing = 4,
20 source = "if_mani",
21 prefix = "●",
22 },
23 severity_sort = true,
24 signs = {
25 text = {
26 [vim.diagnostic.severity.ERROR] = " ",
27 [vim.diagnostic.severity.WARN] = " ",
28 [vim.diagnostic.severity.HINT] = " ",
29 [vim.diagnostic.severity.INFO] = " ",
30 },
31 },
32 },
33 inlay_hints = { enabled = false, },
34 codelens = { enabled = false, },
35 document_highlight = { enabled = true, },
36 capabilities = {
37 workspace = {
38 fileOperations = {
39 didRename = true,
40 willRename = true,
41 },
42 },
43 },
44 format = {
45 formatting_options = nil,
46 timeout_ms = nil,
47 },
48 -- Automatically format on save
49 -- autoformat = false,
50 -- LSP Server Settings
51 ---@type lspconfig.options
52 servers = {
53 lua_ls = {
54 settings = {
55 Lua = {
56 workspace = { checkThirdParty = false, },
57 codeLens = { enable = true, },
58 completion = { callSnippet = "Replace", },
59 doc = { privateName = { "^_" }, },
60 hint = {
61 enable = true,
62 setType = false,
63 paramType = true,
64 paramName = "Disable",
65 semicolon = "Disable",
66 arrayIndex = "Disable",
67 },
68 diagnostics = {
69 disable = { "missing-fields", },
70 },
71 },
72 },
73 },
74 -- Add clangd extensions
75 -- https://github.com/p00f/clangd_extensions.nvim
76 },
77 -- you can do any additional lsp server setup here
78 -- return true if you don't want this server to be setup with lspconfig
79 ---@type table<string, fun(server:string, opts:_.lspconfig.options):boolean?>
80 setup = {
81 -- example to setup with typescript.nvim
82 -- tsserver = function(_, opts)
83 -- require("typescript").setup({ server = opts })
84 -- return true
85 -- end,
86 -- Specify * to use this function as a fallback for any server
87 -- ["*"] = function(server, opts) end,
88 },
89 },
90 },
91
92 -- cmdline tools and lsp servers
93 {
94
95 "williamboman/mason.nvim",
96 cmd = "Mason",
97 keys = { { "<leader>cm", "<cmd>Mason<cr>", desc = "Mason" } },
98 opts = {
99 ensure_installed = {
100 "stylua",
101 "shfmt",
102 -- "flake8",
103 },
104 },
105 ---@param opts MasonSettings | {ensure_installed: string[]}
106 config = function(_, opts)
107 require("mason").setup(opts)
108 local mr = require("mason-registry")
109 local function ensure_installed()
110 for _, tool in ipairs(opts.ensure_installed) do
111 local p = mr.get_package(tool)
112 if not p:is_installed() then
113 p:install()
114 end
115 end
116 end
117 if mr.refresh then
118 mr.refresh(ensure_installed)
119 else
120 ensure_installed()
121 end
122 end,
123 },
124 }