Couple of minor usability things
Looking great! Couple things I came up with:
- [ ] When there is a bit of lag between request and response, "...stderr" appears in the status bar: https://cl.ly/0n2s142Q102q
- [ ] Couldn't get workspace symbols request working, I was running this command:
langserver#symbol#workspace#request("query"), any thoughts? - [ ] Regarding the config file - the JS/TS server will handle js, ts, jsx, and tsx extensions. In the ideal world, we could map all of these without having multiple lines (i.e. [js, ts, tsx, jsx -> entry)
- [ ] In the quick view pane viewing references and the results from workspace symbols, would it be possible to auto-change the main code view as I use my keyboard to scroll through the examples? Or would that be a breaking paradigm for Vim plugins - I don't use enough of them to know what's "common" or "expected" behavior here. I like the VSCode behavior that as you use your keyboard on a list of references, you scroll through them live. Kinda like this: https://cl.ly/3N0b2j1B3s0I
I tried the following to set up the JS/TS server: https://cl.ly/2q1H2T2i0I3j
I think that there is some Vim command to grab the extension, and it might be failing to come up with the extension for a language it doesn't support (I haven't configured Vim for TSX yet) - I tried for "js", and it mentioned that there was no supported langserver for "javascript". When I mapped it to "javascript," on a JS file it worked! So I guess the question here is: do we want to map by extensions or by language name / Vim's ability to recognize the language from a file.
Hey matt:
- I removed the stderr debugging commands :)
- What server were you using for the workspace symbol? I will try and replicate that.
- I'm using the
filetypeas the key for the files right now. You could use autocommands when entering those files to set it to a certain filetype, or we could use some backup for that. Alternatively, we could specify a list of filetypes that correspond to one server. I'll let you know what I figure out. - To move through the commands, you can use
:lnextor:cnextdepending on the request to move through the location list or quickfix list. That will scroll them live. It would be uncommon to move your cursor on them and expect to got there immediately I think.
How does this look?
let g:langserver_executables = {
\ 'go': {
\ 'name': 'sourcegraph/langserver-go',
\ 'cmd': ['langserver-go', '-trace', '-logfile', expand('~/Desktop/langserver-go.log')],
\ },
\ 'python': {
\ 'name': 'sourcegraph/python-langserver',
\ 'cmd': [expand('~/bin/python-langserver/python-langserver.py')],
\ },
\ 'javascript,typescript,jsx,tsx': {
\ 'name': 'javascript-typescript',
\ 'cmd': [],
\ },
\ }
Re: 3 Sick - so in this case, both would work? Could I also specify js,jsx, instead of javascript,jsx? Re: 2: Trying against the go-langserver - and I'm running the `langserver#symbol#workspace#request("NewHandler") as an example - odd! 4: Didn't know that trick - that worked like a charm. Thx!
In reference to the filetype, I'm using vim's built-in filetype system to manage these. So you would still say 'javascript'. You can see what type a file is by doing :echo &filetype when you are in the file. You can read more about it with :help 'filetype'. I think it would not be considered idiomatic vim to use js instead of javascript. The same way you wouldn't want to have to put py for python files, you'd want to say python.
I will look into that same symbol request and see what happens for me.
Also, did you see my message about the fs/readFile command? I think I got it working as I was able to run the python langserver without modification. :D
@tjdevries there was a bug in my vim-lsp response parser. I have fixed and tested it to work with both go and typescript lsp servers. Also it is now capable of handling server instantiated responses like fs/readFile https://github.com/prabirshrestha/vim-lsp/pull/2
I was able to get pure vim-lsp working with typescript. Posted the sample at https://github.com/prabirshrestha/vim-lsp/issues/3#issue-197453543
If you do not pass -s (strict mode) options you will get fs/readFile notification which is non standard.
'cmd': ['node', '/home/username/tmp/javascript-typescript-langserver/build/language-server-stdio', '-s']
Should we support passing custom on_notifications so notifications like fs/readFile can be handled outside the core?
let g:langserver_executables = {
\ 'javascript,typescript,jsx,tsx': {
\ 'name': 'javascript-typescript',
\ 'cmd': ['node', '/home/username/tmp/javascript-typescript-langserver/build/language-server-stdio', '-s'],
\ 'on_notification': function('s:on_notification')
\ },
\ }