]> git.rmz.io Git - dotfiles.git/blob - nvim/lua/plugins/lsp.lua
nvim: configure lsp servers (pylsp, ruff_lsp, lua_ls)
[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 ruff_lsp = {
32 root_dir = function(fname)
33 return require("lspconfig.util").root_pattern("pyproject.toml", "setup.cfg", "ruff.toml")(fname)
34 end,
35 },
36 pylsp = {
37 settings = {
38 pylsp = {
39 plugins = {
40 autopep8 = { enabled = false },
41 flake8 = { enabled = false },
42 mccabe = { enabled = false },
43 pycodestyle = { enabled = false },
44 pydocstyle = { enabled = false },
45 pyflakes = { enabled = false }, -- covered by flake8
46 }
47 }
48 }
49 }
50 },
51 -- you can do any additional lsp server setup here
52 -- return true if you don't want this server to be setup with lspconfig
53 ---@type table<string, fun(server:string, opts:_.lspconfig.options):boolean?>
54 setup = {
55 -- example to setup with typescript.nvim
56 -- tsserver = function(_, opts)
57 -- require("typescript").setup({ server = opts })
58 -- return true
59 -- end,
60 -- Specify * to use this function as a fallback for any server
61 -- ["*"] = function(server, opts) end,
62 },
63 },
64 },
65 }