workin on lsp for nvim
parent
3f55f449b5
commit
551db07d8a
@ -1 +1,4 @@
|
||||
print("You are in lua")
|
||||
vim.opt_local.tabstop = 2
|
||||
vim.opt_local.softtabstop = 2
|
||||
vim.opt_local.shiftwidth = 2
|
||||
vim.opt_local.expandtab = true
|
||||
|
@ -1 +1,37 @@
|
||||
print("You are in Python")
|
||||
local has_pyright = nil
|
||||
|
||||
-- These are files that are typically located in the root directory of a Python
|
||||
-- project
|
||||
local root_files = {
|
||||
'pyproject.toml',
|
||||
'setup.py',
|
||||
'setup.cfg',
|
||||
'requirements.txt',
|
||||
'Pipfile',
|
||||
'pyrightconfig.json',
|
||||
'.git',
|
||||
}
|
||||
|
||||
local buf = vim.api.nvim_get_current_buf()
|
||||
|
||||
local root_dir = vim.fs.root(buf, root_files)
|
||||
local git_dir = vim.fs.root(buf, {'.git'})
|
||||
|
||||
local lsp_server = vim.lsp.start({
|
||||
name = 'pyright',
|
||||
cmd = {'pyright-langserver', '--stdio'},
|
||||
filetypes = { 'python' },
|
||||
root_dir = root_dir,
|
||||
single_file_support = false,
|
||||
settings = {
|
||||
python = {
|
||||
analysis = {
|
||||
autoSearchPaths = true,
|
||||
useLibraryCodeForTypes = true,
|
||||
diagnosticMode = 'openFilesOnly',
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
vim.lsp.buf_attach_client(buf, lsp_server)
|
||||
|
@ -1 +0,0 @@
|
||||
print("LSP setting up")
|
@ -0,0 +1,14 @@
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(args)
|
||||
-- this code is run every time we attach an LSP
|
||||
print("LSP Attached")
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("LspDetach", {
|
||||
callback = function(args)
|
||||
-- this code runs every time a buffer detaches from an LSP
|
||||
end,
|
||||
})
|
||||
|
||||
-- vim.lsp.set_log_level(“DEBUG”)
|
Loading…
Reference in New Issue