u/i-eat-omelettes

How to prevent the command-line "flash" in keymaps
▲ 1 r/neovim

How to prevent the command-line "flash" in keymaps

I'm working on a keymap that generates a half-completed command-line string from buffer context, namely oil.nvim, akin to vim-vinegar behaviour. Right now I have something like:

nnoremap <buffer> . :<C-U><Space><C-R>=<SID>escaped(line('.'),line('.')-1+v:count1)<CR><Home>

It works but there is a kind of cosmetic issue where the command-line would briefly flashes the expression expansion (something like =<SNR>23_escaped(...)) before being replaced by the final string:

It's not breaking anything but still visually distracting

Is there any way to avoid this flash entirely? I have tried <silent> but that seems to break the keymap. Attached my full after/ftplugin/oil.vim if that matters.

let s:oil = luaeval("require('oil')")

nnoremap <buffer> . :<C-U><Space><C-R>=<SID>escaped(line('.'),line('.')-1+v:count1)<CR><Home>
xnoremap <buffer> . <Esc>:<Space><C-R>=<SID>escaped(line("'<"),line("'>"))<CR><Home>
nmap <buffer> ! .!
xmap <buffer> ! .!

function s:escaped(line1, line2) abort
  return range(a:line1, min([line('$'), a:line2]))
        \->map({ _, n -> fnameescape(s:line_get_relpath(n)) })
        \->join(' ')
endfunction

function s:line_get_relpath(n) abort
  let entry = s:oil.get_entry_on_line(0, a:n)
  call assert_notequal(v:null, entry, $'got nil oil entry on line {a:n}')
  let fullpath = s:oil.get_current_dir() .. entry.name
  let relpath = fnamemodify(fullpath, ':.')
  return fullpath is# relpath ? fullpath : './' .. relpath
endfunction
reddit.com
u/i-eat-omelettes — 4 hours ago
▲ 2 r/neovim

How to fix (or suppress) the 'unknown filetype' error in vim.lsp. healthcheck

Taken from :checkhealth vim.lsp:

vim.lsp: Enabled Configurations ~
- ⚠️ WARNING Unknown filetype 'plaintex' (Hint: filename extension != filetype).
- texlab:
  - cmd: { "texlab" }
  - filetypes: tex, plaintex, bib
  - on_attach: <function @/nix/store/l9p60vn64sb7p1b85fdclgy6vz3v9zzq-neovim-unwrapped-450ba41/nvim-packdir/pack/myNeovimPackages/start/nvim-lspconfig/lsp/texlab.lua:165>
  - root_markers: { ".latexmkrc", ".texlabroot", "texlabroot", "Tectonic.toml" }
  - settings: { ... }

To reproduce:

  1. Use nvim-lspconfig
  2. vim.lsp.enable 'texlab'
  3. :checkhealth vim.lsp
reddit.com
u/i-eat-omelettes — 1 month ago