-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
feat(kotlin_language_server): Add storagePath to initilaztion options #2930
Conversation
2c75cc6
to
390eeb0
Compare
@@ -1,9 +1,8 @@ | |||
local util = require 'lspconfig.util' | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lint step was failing in this file, so I reformatted the code. Not related to my original change.
cmd = { 'kotlin-language-server' }, | ||
capabilities = [[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
390eeb0
to
b88fb45
Compare
@@ -24,6 +24,9 @@ return { | |||
filetypes = { 'kotlin' }, | |||
root_dir = util.root_pattern(unpack(root_files)), | |||
cmd = { bin_name }, | |||
init_options = { | |||
storagePath = vim.loop.os_homedir(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why server will use home dir storage data ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using the project workspace is the right place for it but I could figure out a way to get the project root path here. The root_pattern
returns a function. Do you know can I set the project root here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the context the cache file is a single sqlite DB file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
root_pattern return a function then pass current buffer name to it and invoke it again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did it using vim.fn.expand('%:p:h').
First I tried to use vim.api.nvim_buf_get_name(0)
. But root_pattern expects a directory. So I used the fn.expand because it's the short & clear to read. I could not find a one liner in lua APIs to get the current directory.
b4e1ba5
to
ce5fa59
Compare
a04d618
to
aba170e
Compare
@@ -24,6 +24,9 @@ return { | |||
filetypes = { 'kotlin' }, | |||
root_dir = util.root_pattern(unpack(root_files)), | |||
cmd = { bin_name }, | |||
init_options = { | |||
storagePath = util.root_pattern(unpack(root_files))(vim.fn.expand('%:p:h')), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
simply api.nvim_buf_get_name(0)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to use vim.api.nvim_buf_get_name(0). But root_pattern expects a directory.
When I used util.root_pattern(unpack(root_files))(vim.api.nvim_buf_get_name(0))
it was not resolving to the correct path somehow. I thought the root pattern function wants a directory(it was used like this in tests) so I changed it to pass the current directory.
aba170e
to
a8fc471
Compare
a8fc471
to
6e5f020
Compare
Hi @glepnir I'm new to neovim APIs I was trying to figure out how to replace the |
init run before start lsp not in fast loop so it's fine use vim.fn, i will check it later :) |
feature was added in fwcd/kotlin-language-server#337 to help with caching and speeding up the language server.
I did not find the feature documented in the LSP repo to link but it has been used in: