nvim/lua/user/lsp_servers/pyright.lua
Prabhat Maurya 5793c3da7f update
2026-01-29 19:59:22 +05:30

32 lines
1 KiB
Lua

-- Define the configuration for pyright
vim.lsp.config('pyright', {
-- The command to start the server (usually the same as lspconfig's default)
cmd = { "pyright-langserver", "--stdio" },
filetypes = { "python" },
root_markers = { ".git", "pyproject.toml", "setup.py", "requirements.txt" },
-- Your custom settings move here
settings = {
python = {
analysis = {
autoSearchPaths = true,
useLibraryCodeForTypes = true,
},
},
},
})
-- Handle the on_attach logic
vim.api.nvim_create_autocmd('LspAttach', {
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
if client and client.name == 'pyright' then
local bufnr = args.buf
-- Your custom keymaps and commands for pyright go here
-- Example: vim.keymap.set('n', 'K', vim.lsp.buf.hover, { buffer = bufnr })
end
end,
})
-- Finally, enable the server
vim.lsp.enable('pyright')