Conditional mappings if LSP is running #4224
Answered
by
hsanson
pbnj
asked this question in
Q&A - Ask for help with problems
-
|
I would like to set up some mappings only if an LSP server is running. For example: if g:ale_lsp_running == 1
nnoremap gd <cmd>ALEGoToDefinition<cr>
nnoremap K <cmd>ALEHover<cr>
" ... and other LSP-specific mappings for ALEGoToTypeDefinition, ALEGoToImplementation, ALECodeAction, ALEFindReferences, ...etc
endifI have briefly looked through the docs, but didn't find anything relevant that would allow me to check if an LSP is running. Appreciate any ideas/help. |
Beta Was this translation helpful? Give feedback.
Answered by
hsanson
Jun 4, 2022
Replies: 1 comment 1 reply
-
|
I have this in my config. Whenever a LSP is started the ALELSPStarted event is triggered so I have an autocommand that call the ALELSPMappings() to do some configurations. Note this event is called everytime a LSP is started so make sure the method you call can be invoked several times without issues. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
pbnj
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have this in my config. Whenever a LSP is started the ALELSPStarted event is triggered so I have an autocommand that call the ALELSPMappings() to do some configurations.
Note this event is called everytime a LSP is started so make sure the method you call can be invoked several times without issues.