Skip to content

Instantly share code, notes, and snippets.

@eterps
Created May 21, 2025 20:24
Show Gist options
  • Save eterps/1ca92b14de5583657f67e1f0540ff97b to your computer and use it in GitHub Desktop.
Save eterps/1ca92b14de5583657f67e1f0540ff97b to your computer and use it in GitHub Desktop.
{
"mason-org/mason-lspconfig.nvim",
opts = {
ensure_installed = { 'basedpyright', 'ruff', 'prettierd', 'prettier', 'shfmt',
'mdformat', 'standardrb', 'stylua', 'terraform-ls', 'tflint', 'yamlfmt' },
automatic_enable = {
exclude = { "lua_ls", "basedpyright" },
}
},
dependencies = {
{ "mason-org/mason.nvim", opts = {} },
{
"neovim/nvim-lspconfig",
config = function()
local lc = require 'lspconfig'
lc.lua_ls.setup({
settings = { Lua = { diagnostics = { globals = { 'vim', 'describe', 'it' } } } }
})
lc.basedpyright.setup {
root_dir = lc.util.root_pattern('.git', 'pyrightconfig.json'),
settings = {
pyright = {
-- Using Ruff's import organizer
disableOrganizeImports = true,
},
python = {
analysis = {
-- Ignore all files for analysis to exclusively use Ruff for linting
ignore = { '*' },
},
},
},
}
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
callback = function(ev)
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
local opts = { buffer = ev.buf }
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts)
vim.keymap.set('n', '=', function()
vim.lsp.buf.format({ async = true })
end, opts)
end,
})
end
},
},
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment