Beaglefoot / awk-language-server

Language Server for AWK and associated VSCode client extension
https://marketplace.visualstudio.com/items?itemName=beaglefoot.awk-ide-vscode
MIT License
90 stars 5 forks source link

Add nvim-lspconfig configuration example #23

Closed lilibyte closed 2 years ago

lilibyte commented 2 years ago

Will update again if the awk-language-server PR is merged into nvim-lspconfig

Beaglefoot commented 2 years ago

Many thanks!

I really wished someone would join in and show how such configuration is done.

Beaglefoot commented 2 years ago

@lilibyte You might also check 3e854556f9eaef5b69abed055bf0f1157973cd1e. Although I'm not familiar with neovim and lua, so have no idea how viable this solution is in the long run.

lilibyte commented 2 years ago

@Beaglefoot with the changes from https://github.com/Beaglefoot/awk-language-server/commit/3e854556f9eaef5b69abed055bf0f1157973cd1e starting the server now has this error:

[ERROR][2022-01-20 11:39:18] .../vim/lsp/rpc.lua:420    "rpc"   "awk-language-server"   "stderr"    "/usr/lib/node_modules/awk-language-server/out/handlers/handleInitialized.js:18
        const urls = workspaceFolders.flatMap((folder) => io_1.getAwkFilesInDir(folder.uri));
                                      ^

TypeError: workspaceFolders.flatMap is not a function
    at index (/usr/lib/node_modules/awk-language-server/out/handlers/handleInitialized.js:18:39)
    at /usr/lib/node_modules/awk-language-server/out/handlers/handleInitialized.js:36:13
    at Generator.next (<anonymous>)
    at fulfilled (/usr/lib/node_modules/awk-language-server/out/handlers/handleInitialized.js:5:58)

The error is the same when either name and/or uri are set as is.

Beaglefoot commented 2 years ago

@lilibyte Could you please check that what's returned is surrounded by double curly braces (it's list of dictionaries).

I can successfully navigate between different documents in workspace with config example from readme, so I suspect a typo or something.

Could you please also check with diff or vimdiff that there no discrepancies?

diff from_readme_init.vim init.vim
lilibyte commented 2 years ago

@Beaglefoot You're right, sorry. I didn't realize I was getting two different errors. The one about workspaceFolders.flatMap I pasted was due to missing a set of curly braces. The reason I thought that wasn't it is because I still have an error after this: Error: EACCES: permission denied, scandir.

The permission discrepancy is on my end (it's just a random pikaur file in .cache). Since this is happening in the process of a getAwkFilesInDir call, does this suggest that awk-language-server is descending into the entire file tree from the cwd? Would limiting its scanning be something within the neovim config side or on the awk-lsp side?

Beaglefoot commented 2 years ago

Good finding! This is definitely something LS should be able to handle.

Beaglefoot commented 2 years ago

@lilibyte The issue with permissions is resolved in #24 and will be included in the next release.

If you'd like to check right now with master branch, I can provide some instructions on how to do so.

lilibyte commented 2 years ago

@Beaglefoot Thank you, I'll test it. Also, is it possible to optionally prevent LS crawling in the first place to better support the spirit of options like single_file_support?

Beaglefoot commented 2 years ago

@lilibyte I can add an option for CLI mode to skip indexing entirely. In this case only currently opened file will be analyzed. So if you @include some other awk-file, you won't be able to utilize renaming or navigating to symbols across files. Would this suffice?

lilibyte commented 2 years ago

@Beaglefoot Sounds perfect to me

Beaglefoot commented 2 years ago

@lilibyte Now you can start it as awk-language-server --noIndex which prevents crawling.