Skip to content
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

nvim default keybinding overriding plugins bindings #296

Open
afridley opened this issue Apr 23, 2021 · 10 comments
Open

nvim default keybinding overriding plugins bindings #296

afridley opened this issue Apr 23, 2021 · 10 comments

Comments

@afridley
Copy link
Contributor

@afridley afridley commented Apr 23, 2021

When I hit gd I will go to definition in the current function
which you can see from neovim :help index

|gd|		gd		1  go to definition of word under the cursor
				   in current function

however :map shows

n  gd          * <Cmd>lua vim.lsp.buf.definition()<CR>

The weird thing is if I hit gd really fast twice I will get the lsp response and go to the definition in the file its defined in.
This is true for most of the lsp keybindings.

This is with the default installation and LspInstall typescript

@afridley afridley changed the title nvim keybinding overriding plugins bindings nvim default keybinding overriding plugins bindings Apr 23, 2021
@rebuilt
Copy link
Contributor

@rebuilt rebuilt commented Apr 23, 2021

What's the output of

verbose map gd

Do you have python lsp installed and running? What's the output of:

:LspInfo

If I remember correctly a keymapping gets created and attached to the buffer when an lsp client is created. They are not attached to the buffer if the current filetype has no defined lsp settings. This doesn't explain why they would work sometimes and not others. But check your lsp settings to make sure everything is in place first.

@afridley
Copy link
Contributor Author

@afridley afridley commented Apr 23, 2021

verbose map gd: n gd * <Cmd>lua vim.lsp.buf.definition()<CR>
:LspInfo :

Configured servers: html, jsonls, kotlin_language_server, tailwindls, emmet_ls, cssls, dartls
Neovim logs at: /home/x2/.cache/nvim/lsp.log

0 client(s) attached to this buffer: 

1 active client(s): 

  Client: tsserver (id 1)
  	root:      /home/x2/Sites/webapp
  	filetypes: javascript, javascriptreact, javascript.jsx, typescript, typescriptreact, typescript.tsx
  	cmd:       /home/x2/.local/share/nvim/lspinstall/typescript/node_modules/.bin/typescript-language-server --stdio
  	


Clients that match the filetype typescript:
  
  Config: tailwindls
  	cmd:               node /home/x2/.local/share/nvim/lspinstall/tailwindcss/tailwindcss-intellisense/extension/dist/server/index.js --stdio
  	cmd is executable: True
  	identified root:   /home/x2/Sites/webapp
  	custom handlers:   tailwindcss/getConfiguration

I dont have python installed but im using it for typescript. Its working for completion and I can type :LspDefinition which works fine.

Just when using keybindings it doesnt work

@rebuilt
Copy link
Contributor

@rebuilt rebuilt commented Apr 23, 2021

Do you have more than one file open? It shows that the current file does not have lsp active but another one does. Whatever file is in the current buffer will not have lsp keybindings attached to it. The other file is the one that has keybindings attached to its buffer.

@afridley
Copy link
Contributor Author

@afridley afridley commented Apr 23, 2021

sorry when I copied that I was in a config on one tab.
But yeah it still doesnt work unless I use it twice on the .tsx file

@rebuilt
Copy link
Contributor

@rebuilt rebuilt commented Apr 23, 2021

Try running it as an ex command. I want to see if you experience other weird behavior.

:lua vim.lsp.buf.definition()

Then try :messages to see if there were any errors

Also try to bind it to a different mapping. See if that changes anything.

@afridley
Copy link
Contributor Author

@afridley afridley commented Apr 24, 2021

It worked fine with

:lua vim.lsp.buf.definition()

in messages I get
Client 3 quit with exit code 1 and signal 0

Configured servers: html, efm, gopls, yamlls, dockerls, rust_analyzer, intelephense, kotlin_language_server, sumneko_lua, tailwindls, texlab, bashls, clangd, svelte, terraformls, emmet_ls, tsserver, cssls, dartls, vimls, graphql, pyright, jsonls, solargraph
Neovim logs at: /home/x2/.cache/nvim/lsp.log

1 client(s) attached to this buffer: tsserver

  Client: tsserver (id 1)
  	root:      /home/x2/Sites/webapp
  	filetypes: javascript, javascriptreact, javascript.jsx, typescript, typescriptreact, typescript.tsx
  	cmd:       /home/x2/.local/share/nvim/lspinstall/typescript/node_modules/.bin/typescript-language-server --stdio
  	


1 active client(s): 

  Client: tsserver (id 1)
  	root:      /home/x2/Sites/webapp
  	filetypes: javascript, javascriptreact, javascript.jsx, typescript, typescriptreact, typescript.tsx
  	cmd:       /home/x2/.local/share/nvim/lspinstall/typescript/node_modules/.bin/typescript-language-server --stdio
  	


Clients that match the filetype typescriptreact:
  
  Config: tailwindls
  	cmd:               node /home/x2/.local/share/nvim/lspinstall/tailwindcss/tailwindcss-intellisense/extension/dist/server/index.js --stdio
  	cmd is executable: True
  	identified root:   /home/x2/Sites/webapp
  	custom handlers:   tailwindcss/getConfiguration
  
  Config: tsserver
  	cmd:               /home/x2/.local/share/nvim/lspinstall/typescript/node_modules/.bin/typescript-language-server --stdio
  	cmd is executable: True
  	identified root:   /home/x2/Sites/webapp
  	custom handlers:   textDocument/publishDiagnostics

if i bind it to something that neovim doesnt use defaultly it works fine

@rebuilt
Copy link
Contributor

@rebuilt rebuilt commented Apr 24, 2021

At some point in time a server tried to start but most likely could not identify a root. Open each different kind of file you edit and see which lsp server is failing with :LspInfo

@rebuilt
Copy link
Contributor

@rebuilt rebuilt commented Apr 24, 2021

Also, the status bar will tell you if a language server is loaded or not. If there's no language server attached to the current buffer it will read 'No Active Lsp'.

@afridley
Copy link
Contributor Author

@afridley afridley commented Apr 24, 2021

Ive disabled everything in the init.lua file and reenabled one by one

with vim.api.nvim_set_keymap('n', 'gd', '', {}) at the top of the init
I got no jumping to definition until I hit

require('settings')

I think my problem may be in there.

It looks like its not just lsp stuff I cant rebind any keybinding set by neovim by default.
double inputing it will give me what I bind it too. Even if its non lsp related

@afridley
Copy link
Contributor Author

@afridley afridley commented Apr 24, 2021

This line is what's causing it for me

vim.o.timeoutlen = 100 -- By default timeoutlen is 1000 ms

commenting that out fixes the issue

in fact changing it to 200 fixes it aswell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants