New answers tagged

0

As per Neovim issue #14543 this appears to be a Flatpak issue. after installing the flatpak io.neovim.nvim you can't run e.g. :terminal or say !latexmk as /usr/bin and there a like are not accessible from within the flatpak. I switched back to the regular dnf package for Neovim and the problem goes away.


1

What you're seeing in that output is a list of all defined auto-commands. You get Vim/NeoVim to list all defined auto-commands with the Ex command autocmd with no arguments. This command can be abbreviated to simply au or auto. So in order to have Vim/NeoVim display all defined auto-commands at startup, you probably have an auto in your vimrc or init.vim (...


0

With a few mappings, vim becomes an excellent terminal multiplexer, and tmux becomes unnecessary. In addition to the features you have listed (which are all possible with tmux), using terminal buffers directly inside (neo)vim provides some additional features tmux can't match: completion inside e.g. the git commit message buffer can autocomplete terminal ...


0

An onoremap will not act on anything if you exit the function without moving the cursor, so you should try to do that. Your initial calls to searchpos() don't include the n flag, so they're doing that. Here's a very simple and naive proof of concept (in pure Vimscript) to show how this works: function! FindStar() let [_, s] = searchpos('*', 'bcn', line('.')...


2

You need to use redraw after setting relativenumber with the CmdLineEnter event: augroup SmartNumberGroup autocmd! autocmd CmdLineEnter * set norelativenumber|redraw autocmd CmdLineLeave * set relativenumber augroup END I didn't do it in lua but it should work the same. Also note that you probably want to have this behavior happening only when ...


1

@mattb's reply gave me an idea to map additional function to <C-o> and <C-i> and it seems to be working alright. vim.api.nvim_set_keymap("n", "<C-o>", "<C-o>:lua require('util').flash_cursorline()<CR>", { noremap = true, silent = true }) vim.api.nvim_set_keymap("n", "<C-i>",...


1

You get a hashed value because nvim_win_get_cursor() returns a tuple (row, col). You can show the value with: print(unpack(lineNum)) You can also get the row and column in two variables with this: local r,c = unpack(vim.api.nvim_win_get_cursor(0)) print(r, c) You might be interested in this SO answer. Also note that I am not really a Lua expert so the code ...


1

I use a mapping <LEADER>/ so I can toggle highlighting on and off: nnoremap <silent><expr> <LEADER>/ \ (&hls && v:hlsearch ? ':nohls' : ':set hls')."\n" I found that the above would highlight the last searched term when I opened vim, which I found irritating, but I fixed that by adding | noh to the ...


1

I wrote a few functions to do 'delete', 'change', and 'yank' in between, and 'around' two characters on a line, which are called using normal mode commands: function! DeleteInside(char) execute "normal! F".a:char execute "normal! ldt".a:char endfunction function! DeleteAround(char) execute "normal! F".a:char ...


0

As mentioned on the FAQ for vim-airline (which is the Vim plug-in adding the mode to your status bar), in this question: How do I get rid of the default mode indicator? Add set noshowmode to your vimrc.


0

You can use winsaveview() and winrestoreview() to restore the view across the :edit operation. At this point, it's much easier if you define a function to perform the operation: function! SwiftFormat() silent !swiftformat % let view = winsaveview() silent edit call winrestview(view) redraw! endfunction augroup swiftFormat autocmd! ...


2

I tracked it down to an Xterm resource setting in my $XAPPLRESDIR/XTerm file. To allow shifted function keys, I have specified *keyboardType: sun The sequence generated by Xterm for F1 with this setting is <ESC>[224z, Shift-F1 is <ESC>[224;2z. If I remove/comment this resource line, neovim recognizes F1 (Xterm sends <ESC>[OP). However, ...


3

The problem here is that you are mixing two types of completion "backends": The built-in omni completion and the automatic completion by coc.nvim. VimTeX provides an omni-complete function which is connected to the standard CTRL-X CTRL-O key combo. When you write \cite{efg then type CTRL-X CTRL-O, then the completion works "as expected", ...


2

If you're running that code block from inside a vimrc file (or init.vim for NeoVim), that will explain why the :Fern command will not be available yet, since the code in a vimrc will run before plug-in initialization code is executed and custom plug-in commands are only defined there. In order to have the call only happen once plug-ins have initialized (at ...


0

In order to load the plugins, you have to wrap your Plug part with call plug#begin(<path>) and call plug#end(). So it should look like this for example: call plug#begin('~/.vim/plugged') Plug 'neovim/nvim-lspconfig' Plug 'nvim-lua/completion-nvim' call plug#end() lua require('lspconfig').tsserver.setup{}


5

This is a coc.nvim setup procedure that works for Neovim, which aims to: Provide static type checking from a Python virtualenv (e.g. I have created a venv called coc with pyenv, which resides in ~/.pyenv/versions, I'll use this as an example). Format with black manually and automatically on save. So here is my setup procedure: Configure venv in coc-...


2

You can change the encoding of a loaded buffer simply by setting 'fileencoding' and then saving the file: :set fileencoding=utf-8 :w Hopefully this will allow your plugin to work, and then if necessary you can change the encoding back afterwards using the same method. You could probably also set up a BufUnload or BufDelete autocommand to automatically ...


1

I believe your best bet is to utilize the command :NERDTreeCWD: :NERDTreeCWD *:NERDTreeCWD* Change the NERDTree root to the current working directory. If no NERDTree exists for this tab, a new one is opened. Now you can't override :cd but you could create a custom command that's close...it just ...


4

The reason for the warning message is that Vim, in its default configuration, is an interactive application which expects to communicate using a particular terminal configuration. When you instead run things non-interactively from a shell command-line context Vim doesn't like it and complains. For a slightly more technical explanation I'll quote Invoking vi ...


8

<plug> mappings are meant as customization points. Not everyone will want to use the same shortcut/keybinding as the one chosen by the author of a plugin. That's where <plug> mappings come in handy. The plugin author can provide a default keybinding (for a given feature of his/her plugin) and still permit end users of the plugin to use another ...


11

This is used by plugin authors to make complex mappings available to the user. In a plugin code you define a mapping with <plug>... which is not a real key sequence but which can be used as a right hand side expression in a mapping by your users. As an example take this line of code from vim-subversive: nnoremap <silent> <plug>(...


1

A substitution like this works for all scenarios: %s/print(\(.*\))/log.info(" ".join([\1]))/ Grab everything within print brackets (.*) using regex replace the match with a join statement surrounding the match replace the print with log.info (or whatever is required) Here is the test script if anyone wants to try it for themselves: import logging,...


Top 50 recent answers are included