How to use neovim lsp keybindings? - neovim

I have neovim 0.6.1 configured with some LSPs and using the default configurations found here: https://github.com/neovim/nvim-lspconfig#suggested-configuration. Some of the key bindings such as vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts) are not working.
The vim.lsp.buf.rename() command works correctly if I call it manually like :lua vim.lsp.buf.rename().
If I do :noremap <space>rn :lua vim.lsp.buf.rename()<CR> during a session the rename keybinding works correctly.

The default config from nvim-cmp was also calling setup{} which effectively cleared the on_attach callback required to enable the lsp keybindings.

Related

How to apply multiple auto fixes with nvim LSP

In nvim, using LSP, i want to be able to apply a 'fix all of the same type' similar to what can be done in VSCode (see picture). How would one go about adding this to LSP code actions?
Edit: I know this can be done using COC. But i want it for LSP.
It depends on the language server you are using, in my current NeoVim configuration I'm running both ESLint and tsserver and with a default configuration of ESLint in my root of my project, I get these types of code action.
Assuming you are using lspconfig plugin you need to make sure you have the server configured :
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
require('lspconfig')['tsserver'].setup {
on_attach = function() end,
capabilities = capabilities,
}
require('lspconfig')['eslint'].setup {
on_attach = function() end,
capabilities = capabilities,
}
You can then run in neovim : :lua vim.lsp.buf.code_action() in command mode (n)
You need both LSP installed manually
Ref :
https://github.com/neovim/nvim-lspconfig#quickstart
https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#eslint
https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#tsserver
N.B. You should probably add your keymap related to LSP in the on_attach callback

How do I get vim user Shortcuts to work in vscode

vscode > Preferences: Open Settings (JSON)
{
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["t", "s"],
"commands": ["python.sortImports"],
}
]
}
I set it up as above, but it doesn't work. What could be wrong?
I'm typing 't' and 's' in vim-normal mode.
ctrl+alt+s is woring. but i wanna have custom vim shortcuts
Try reinstalling the vim extension. If this fails, you could try the following:
Are your configurations correct?
Adjust the extension's logging level to 'debug', restart VS Code. As each > remapped configuration is loaded, it is outputted to console. In the Developer > Tools console, do you see any errors?
debug: Remapper: normalModeKeyBindingsNonRecursive. before=0. after=^.
debug: Remapper: insertModeKeyBindings. before=j,j. after=<Esc>.
error: Remapper: insertModeKeyBindings. Invalid configuration. Missing 'after' key or 'command'. before=j,k.
Misconfigured configurations are ignored.
Does the extension handle the keys you are trying to remap?
VSCodeVim explicitly instructs VS Code which key events we care about through > the package.json. If the key you are trying to remap is a key in which vim/vscodevim generally does not handle, then it's most likely that this extension does not receive those key events from VS Code. With logging level adjusted to 'debug', as you press keys, you should see output similar to:
debug: ModeHandler: handling key=A.
debug: ModeHandler: handling key=l.
debug: ModeHandler: handling key=<BS>.
debug: ModeHandler: handling key=<C-a>.
As you press the key that you are trying to remap, do you see it outputted here? If not, it means we don't subscribe to those key events. It is still possible to remap those keys by using VSCode's keybindings.json.
Source: https://marketplace.visualstudio.com/items?itemName=vscodevim.vim#debugging-remappings

How to activate/deactivate plugins for svgo

I have installed svgo like so:
[sudo] npm install -g svgo
Downloaded the default config from repo:
https://github.com/svg/svgo/blob/master/.svgo.yml
Edited the config like so:
...
- minifyStyles
- convertStyleToAttrs
- cleanupIDs: false
- removeRasterImages
- removeUselessDefs
...
Replaced the default like so:
svgo --config=custom.yml
As described here:
https://github.com/svg/svgo#cli
I run SVGO like so:
svgo test.svg test.min.svg
...but the plugin I've deactivated (cleanupIDs) is still active.
I've tried to deactivate other plugins too (i.e. removeTitle) but there is no effect on my output file.
Appreciate some guidance!
You can specify the plugin you want enabled or disabled by name, directly in your command line interface:
svgo --enable={cleanupIDs} test.svg -o test.min.svg
This will ensure that the named plugin(s) will be enabled if they are disabled by default, see help screen:
svgo -h
will produce this help screen: https://github.com/svg/svgo#cli where you can find this piece of information:
--disable=PLUGIN : Disable plugin by name,
--enable=PLUGIN : Enable plugin by name,
svgo --show-plugins
will actually show which plugins are available and which are disabled by default.
Maybe you need to specify a parameter at the beginning of the custom.yml full: true

Use inputrc inside sbt

I would like these settings to work seamless in my shell as well as in sbt.
Is there something special I need to do to get these working?
My ~/.inputrc:
\C-Space:complete
\C-i:menu-complete
"\C-f": forward-word
"\C-b": backward-word
"\u26F5": unix-word-rubout
"\C-w": backward-kill-word
"\e[B": history-search-forward
"\e[A": history-search-backward

Specify --no-highlight-code in Babel Require Hook options

How to specify the --no-highlight-code option in Babel's Require Hook options object?
require('babel/register')({
'--no-highlight-code': true,
'no-highlight-code': true,
'noHighlightCode': true,
});
require('./script');
All of those give the error Unknown option: no-highlight-code
It's an option present Babel's command line usage, so I'm not even sure if I'm supposed to use it like that, although the example page lists blacklist and whitelist could be used ..
babel --help
Usage: index [options] <files ...>
Options:
-h, --help output usage information
-f, --filename [string] filename to use when reading from stdin - this will be used in source-maps, errors etc
--module-id [string] specify a custom name for module ids
--retain-lines retain line numbers - will result in really ugly code
--no-non-standard enable/disable support for JSX and Flow (on by default)
--experimental allow use of experimental transformers
--no-highlight-code enable/disable ANSI syntax highlighting of code frames (on by default)
-e, --stage [number] ECMAScript proposal stage version to allow [0-4]
The option to disable highlighting code is (by default) on, and the command line option has the (added) prefix "no".
require("babel/register")({ highlightCode: false }) is the way to disable highlighting code in parse time SyntaxErrors when passing an object to babel/register.
Passing { highlightCode: true } does nothing; the default is true.