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