-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lua lsp uses always current work dir when LSP initalized when editing file #512
Comments
For the time being, a partial workaround is defering the addition of the lua server up to the point that a Lua file has been openend and the project root set as work dir by adding to if !empty(FugitiveGitDir()) | Glcd | endif
if !exists('##vimrcFileTypeLuaLsp')
augroup vimrcFileTypeLuaLsp
autocmd BufWinEnter <buffer> call LspAddServer(lspLuaServers)
\ | autocmd! vimrcFileTypeLuaLsp
augroup END
endif where let lspLuaServers = [
\ #{ name: 'lua',
\ filetype: ['lua'],
\ path: 'lua-language-server'
\ }] |
Is there a better workaround to change the current work dir from the initial one (the current work at the start of vim)? |
Cleaner would be to set up |
Only set workspace root once the first file of that file type is opened; otherwise the workspace root often is $HOME (say when using Gvim, or opening a file in a Git repo) and the LS scans too many files Partially resolves [0] as ideally this workspace root would automatically change with the CWD, in particular after loading a session (:h mksession) Links: [0]: yegappan#512
Only set workspace root once the first file of that file type is opened; otherwise the workspace root often is $HOME (say when using Gvim, or opening a file in a Git repo) and the LS scans too many files Partially resolves [0] as ideally this workspace root would automatically change with the CWD, in particular after loading a session (:h mksession) Links: [0]: yegappan#512
According to the LSP logs, the root directory is always that of the current working directory when the LSP was added:
In
/path/to/lua-language-server/log/
a log file for this working directory shows up containingafter Vim was started in
~/
, editing a file in a project dir below~/
, throwing an error that more than 100000 files were scanned.Instead, one would expect the rootPath to be set to the current working directory.
According to https://luals.github.io/wiki/faq/#why-is-the-server-scanning-the-wrong-folder
I am using latest LSP master and Vim 9.1.369 on Ubuntu 22.04
The text was updated successfully, but these errors were encountered: