Closed madhavpcm closed 1 year ago
I'll see if I can go through the instructions with a fresh installation later, here are a few questions,
which version of vim and how are you starting it up, there are known issues when you open e.g. a directory nvim foo/
where the directory contains a nimbleparse.toml
, vs a file nvim foo/foo.y
.
Presumably from the screenshot you have a .y file open, and it knows the . Does it work if you manually run :LspStart nimbleparse_lsp
?
Is there anything relevant in that lsp.log file shown in the screenshot?
One last question, It could also be that it may require a nimbleparse.toml
to exist (speculation), and just opening a .y
file alone
isn't triggering startup, try opening one of the files like tests/badproject/src/rr.y
and see if that manages to trigger it.
So, the main thing that sticks out to me looking at your code snippet is the line require("lsp.handlers").setup()
.
In the neovim/README.md we call setup with a custom on_attach
function, which is where it configures file extensions,
so I wonder if it is this call to setup without the associated on_attach
key?
nimbleparse_lspconfig = {
{
on_attach = nimbleparse_lsp_attach,
cmd = cmd,
}
require 'lspconfig'[name].setup(nimbleparse_lspconfig)
which version of vim and how are you starting it up
NVIM v0.8.2
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by builduser
Features: +acl +iconv +tui
See ":help feature-compile"
I do nvim .
in my project dir
Does it work if you manually run
:LspStart nimbleparse_lsp
?
No, after doing this, If I do LspInfo, it still shows 0 clients attached.
Is there anything relevant in that lsp.log file shown in the screenshot?
There are no logs, just says
One last question, It could also be that it may require a
nimbleparse.toml
to exist (speculation), and just opening a.y
file alone isn't triggering startup, try opening one of the files liketests/badproject/src/rr.y
and see if that manages to trigger it.
These are the logs, I think it is triggered but I get errors in nvim
[START][2023-01-22 11:35:02] LSP logging initiated
[INFO][2023-01-22 11:35:02] .../vim/lsp/rpc.lua:661 "Starting RPC client" { args = { "--server" }, cmd = "/home/madhavpcm/.cargo/bin/nimbleparse_lsp", extra = { cwd = "/home/madhavpcm/test/nimbleparse_lsp/tests/badproject" }}
[INFO][2023-01-22 11:35:02] .../lua/vim/lsp.lua:1336 "LSP[nimbleparse_lsp]" "server_capabilities" { server_capabilities = { completionProvider = vim.empty_dict(), hoverProvider = true, textDocumentSync = { change = 2, openClose = true, save = { includeText = false }, willSave = false, willSaveWaitUntil = false } }}
[INFO][2023-01-22 11:35:02] ...lsp/handlers.lua:489 "initializing..."
[INFO][2023-01-22 11:35:04] ...lsp/handlers.lua:489 "initialized!"
[INFO][2023-01-22 11:35:04] ...lsp/handlers.lua:489 "did_open file:///home/madhavpcm/test/nimbleparse_lsp/tests/badproject/src/rr.y"
[INFO][2023-01-22 11:35:04] ...lsp/handlers.lua:489 '"Rebuilding parser: /home/madhavpcm/test/nimbleparse_lsp/tests/badproject/src/unused_token.l /home/madhavpcm/test/nimbleparse_lsp/tests/badproject/src/unused_token.y"'
[INFO][2023-01-22 11:35:04] ...lsp/handlers.lua:489 '"Evaluating changes {}"'
[INFO][2023-01-22 11:35:04] ...lsp/handlers.lua:489 '"Finished changes"'
[INFO][2023-01-22 11:35:04] ...lsp/handlers.lua:489 '"Rebuilding parser: /home/madhavpcm/test/nimbleparse_lsp/tests/badproject/src/sr.l /home/madhavpcm/test/nimbleparse_lsp/tests/badproject/src/sr.y"'
[INFO][2023-01-22 11:35:04] ...lsp/handlers.lua:489 '"Rebuilding parser: /home/madhavpcm/test/nimbleparse_lsp/tests/badproject/src/whitespace.l /home/madhavpcm/test/nimbleparse_lsp/tests/badproject/src/rr.y"'
[INFO][2023-01-22 11:35:04] ...lsp/handlers.lua:489 '"Rebuilding parser: /home/madhavpcm/test/nimbleparse_lsp/tests/badproject/src/whitespace.l /home/madhavpcm/test/nimbleparse_lsp/tests/badproject/src/rr.y"'
[INFO][2023-01-22 11:35:04] ...lsp/handlers.lua:489 '"DidOpen"'
[START][2023-01-22 11:35:12] LSP logging initiated
[INFO][2023-01-22 11:35:12] .../lua/vim/lsp.lua:1807 "exit_handler" {}
and this
But the buffer is being attached. So I'm assuming we need to setup a nimbleparse.toml file ?
Update: I added a nimbleparse.toml file in my project
yacc_kind = {"Original" = "NoAction"}
l_file = "src/lexer.l"
y_file = "src/parser.y"
extension = ".expl"
``` but this doesnt work as well ? am I doing something wrong ?
One last question, It could also be that it may require a
nimbleparse.toml
to exist (speculation), and just opening a.y
file alone isn't triggering startup, try opening one of the files liketests/badproject/src/rr.y
and see if that manages to trigger it.These are the logs, I think it is triggered but I get errors in nvim
[START][2023-01-22 11:35:02] LSP logging initiated [INFO][2023-01-22 11:35:02] .../vim/lsp/rpc.lua:661 "Starting RPC client" { args = { "--server" }, cmd = "/home/madhavpcm/.cargo/bin/nimbleparse_lsp", extra = { cwd = "/home/madhavpcm/test/nimbleparse_lsp/tests/badproject" }} [INFO][2023-01-22 11:35:02] .../lua/vim/lsp.lua:1336 "LSP[nimbleparse_lsp]" "server_capabilities" { server_capabilities = { completionProvider = vim.empty_dict(), hoverProvider = true, textDocumentSync = { change = 2, openClose = true, save = { includeText = false }, willSave = false, willSaveWaitUntil = false } }} [INFO][2023-01-22 11:35:02] ...lsp/handlers.lua:489 "initializing..." [INFO][2023-01-22 11:35:04] ...lsp/handlers.lua:489 "initialized!" [INFO][2023-01-22 11:35:04] ...lsp/handlers.lua:489 "did_open file:///home/madhavpcm/test/nimbleparse_lsp/tests/badproject/src/rr.y" [INFO][2023-01-22 11:35:04] ...lsp/handlers.lua:489 '"Rebuilding parser: /home/madhavpcm/test/nimbleparse_lsp/tests/badproject/src/unused_token.l /home/madhavpcm/test/nimbleparse_lsp/tests/badproject/src/unused_token.y"' [INFO][2023-01-22 11:35:04] ...lsp/handlers.lua:489 '"Evaluating changes {}"' [INFO][2023-01-22 11:35:04] ...lsp/handlers.lua:489 '"Finished changes"' [INFO][2023-01-22 11:35:04] ...lsp/handlers.lua:489 '"Rebuilding parser: /home/madhavpcm/test/nimbleparse_lsp/tests/badproject/src/sr.l /home/madhavpcm/test/nimbleparse_lsp/tests/badproject/src/sr.y"' [INFO][2023-01-22 11:35:04] ...lsp/handlers.lua:489 '"Rebuilding parser: /home/madhavpcm/test/nimbleparse_lsp/tests/badproject/src/whitespace.l /home/madhavpcm/test/nimbleparse_lsp/tests/badproject/src/rr.y"' [INFO][2023-01-22 11:35:04] ...lsp/handlers.lua:489 '"Rebuilding parser: /home/madhavpcm/test/nimbleparse_lsp/tests/badproject/src/whitespace.l /home/madhavpcm/test/nimbleparse_lsp/tests/badproject/src/rr.y"' [INFO][2023-01-22 11:35:04] ...lsp/handlers.lua:489 '"DidOpen"' [START][2023-01-22 11:35:12] LSP logging initiated [INFO][2023-01-22 11:35:12] .../lua/vim/lsp.lua:1807 "exit_handler" {}
This seems like the neovim is registering and starting it up appropriately
and this
The image which seems to be having an issue configuring the LSP/registering file extensions within the editor, but then in the log file earlier it actually seems to indicate the lsp actually being initialized by the editor, so I am a bit confused how we're encountering both of these errors, would kind of expect one or the other.
But the buffer is being attached. So I'm assuming we need to setup a nimbleparse.toml file ?
Yeah, it is currently necessary (albeit somewhat unfortunately) to have a nimbleparse.toml file as it is required to parse the yacc file.
Update: I added a nimbleparse.toml file in my project
yacc_kind = {"Original" = "NoAction"} l_file = "src/lexer.l" y_file = "src/parser.y" extension = ".expl" ``` but this doesnt work as well ? am I doing something wrong ?
is this section within a [[parsers]]
, which is just shorthand for parsers = [ { yacc_kind = {"Original" = "NoAction"}, ...} ]?
So, I did run with neovim 0.8.2 locally, and confirm that that works fine with my existing configuration, and I basically get the same lsp.log output as you. I did have a peek through your dotfiles repo. I wonder if there could be some form of conflict arising from https://github.com/madhavpcm/dotfiles/blob/arch/.config/nvim/lua/lsp/handlers.lua#L87
I'm not sure though if this line actually runs for nimbleparse_lsp, but can imagine that if it does it might conflict with the nimbleparse_on_attach function from https://github.com/ratmice/nimbleparse_lsp/tree/main/neovim.
So, I was able to reproduce using your dotfiles, and fllowing is a commit which gets it working,
I moved the lsp.handlers.setup()
up above loading lsp.nimbleparse
, then called lsp.handlers.on_attach
instead of the non-existent global one. This fix is pretty specific to your config though, I'm not exactly sure yet if there is a way to get this to work generally across configs.
The problem kind of is that on_attach
is meant for user configuration stuff, but we need to override it, and then call the user original one given by the user configuration.
Hopefully that works for you too?
https://github.com/ratmice/madhavpcm-dotfiles/commit/54fab46675419bf451ed0dcfc4a74c2b6eb3713d
So, I was able to reproduce using your dotfiles, and fllowing is a commit which gets it working, I moved the
lsp.handlers.setup()
up above loadinglsp.nimbleparse
, then calledlsp.handlers.on_attach
instead of the non-existent global one. This fix is pretty specific to your config though, I'm not exactly sure yet if there is a way to get this to work generally across configs.The problem kind of is that
on_attach
is meant for user configuration stuff, but we need to override it, and then call the user original one given by the user configuration.Hopefully that works for you too?
Thanks alot for your time to fix this (this does fix the badproject dir), however in my project I have been using YaccKind::Grmtools, Im not sure how the toml file would look like, so far I added nimbleparse.toml (in project root) with contents :-
[[parsers]]
l_file = "src/lexer.l"
y_file = "src/parser.y"
extension = ".expl"
Where expl files are to be compiled to an assembly language. This is the project. Will this lsp work with grmtools format of y files?
I need to document this better, I believe the complete list of support yacc_kind's is below: Grmtools kind should work (although it is one of the formats I don't believe that I've used/tested), It won't do anything with embedded actions, like syntax highlight them with rust-analyzer, or generate code and check for syntax errors in the generated code, or actually run the actions.
In theory at least for now it should just ignore embedded actions, and if that is not the case please file a bug for that!
yacc_kind = {"Original" = "NoAction"}
yacc_kind = {"Original" = "UserAction"}
yacc_kind = {"Original" = "GenericParseTree"}
yacc_kind = "Eco"
yacc_kind = "Grmtools"
I need to document this better, I believe the complete list of support yacc_kind's is below: Grmtools kind should work (although it is one of the formats I don't believe that I've used/tested), It won't do anything with embedded actions, like syntax highlight them with rust-analyzer, or generate code and check for syntax errors in the generated code, or actually run the actions.
In theory at least for now it should just ignore embedded actions, and if that is not the case please file a bug for that!
yacc_kind = {"Original" = "NoAction"} yacc_kind = {"Original" = "UserAction"} yacc_kind = {"Original" = "GenericParseTree"} yacc_kind = "Eco" yacc_kind = "Grmtools"
Thanks for your inputs. I guess I'll mark this as solved, I am looking forward to add embedded actions sometime in the future when I get time.
I setup the config according to the guide. If I do![image](https://user-images.githubusercontent.com/59736487/213859090-e3499dd5-01a7-4e04-a21e-f8cc4a17a157.png)
:LspInfo
I get the following output but the buffer is not being attached ?this is my LSP loading init file, where lsp.nimbleparse loads the given config. I used packer to install lspconfig. Am I missing something ?