lervag / vimtex

VimTeX: A modern Vim and neovim filetype plugin for LaTeX files.
MIT License
5.29k stars 386 forks source link

how do I unmap just some mappings? #2962

Closed DWIAltonaAnalytics closed 1 month ago

DWIAltonaAnalytics commented 1 month ago

Description

this might be related to #1673 or #1783 but these did not help me.

I use vimtex throug vims package mechanism, and have it in pack/foo/start/vimtex/

I use a dvorak keyboard layout and have remapped some keys, I end up using t instead of j to move down.

now this conflicts with all the nmap from vimtex starting with a t, and everytime I want to move down a line, there is that pesky wait until the cursor moves.

I tried different approaches:

adding nunmap t** to $vim/after/tex.vim and my vimrc but that did not remove the mappings, I get an error that these mappings do not exist. if I do packloadall in my vimrc it is still the same.

I added mappings for t** stuff in my vimrc, called packloadall and then removed them again, but that didn't help either.

how can I remove just some of the mappings VimTeX provides without disabling them all?

Steps to reproduce

load vimtex with vims package mechanism

have no t j in your vimrc, open a latex file and try to move the cursor down by pressing t

wait for a tiny bit to see the cursor move.

Expected behavior

I can unmap any mapping created by vimtex

Actual behavior

unmapping does not work.

Do you use a latexmkrc file?

no

VimtexInfo

System info:
  OS: Ubuntu 22.04.4 LTS
  Vim version: VIM 8.2 (1-579, 1969, 580-1848, 4975, 5016, 5023, 5072, 2068, 1849-1854, 1857, 1855-1857, 1331, 1858, 1858-1859, 1873, 1860-1969, 1992, 1970-1992, 2010, 1993-2068, 2106, 2069-2106, 2108, 2107-2109, 2109-3995, 4563, 4646, 4774, 4895, 4899, 4901, 4919, 213, 1840, 1846-1847, 2110-2112, 2121)
  Has clientserver: true
  Servername: undefined (vim started without --servername)

VimTeX project: Quarterly_2024_05_31
  base: Quarterly_2024_05_31.tex
  root: /home/dirk/projects/talks/Quarterly
  tex: /home/dirk/projects/talks/Quarterly/Quarterly_2024_05_31.tex
  main parser: current file verified
  document class: beamer
  packages: amsbsy amsfonts amsgen amsmath amsopn amssymb amstext amsthm array atbegshi atbegshi-ltx atveryend atveryend-ltx auxhook babel beamerbaseauxtemplates beamerbaseboxes beamerbasecolor beamerbasecompatibility beamerbasedecode beamerbasefont beamerbaseframe beamerbaseframecomponents beamerbaseframesize beamerbaselocalstructure beamerbasemisc beamerbasemodes beamerbasenavigation beamerbasenotes beamerbaseoptions beamerbaseoverlay beamerbaserequires beamerbasesection beamerbasetemplates beamerbasethemes beamerbasetheorems beamerbasetitle beamerbasetoc beamerbasetranslator beamerbasetwoscreens beamerbaseverbatim beamercolorthemedefault beamerfontthemedefault beamerinnerthemedefault beamerouterthemedefault beamerthemedefault bigintcalc bitset calc color csquotes enumerate epstopdf-base etoolbox fontenc geometry gettitlestring graphics graphicx hycolor hyperref iftex ifthen ifvtex infwarerr inputenc intcalc keyval kvdefinekeys kvoptions kvsetkeys letltxmacro ltxcmds nameref pdfescape pdftexcmds pgf pgfcomp-version-0-65 pgfcomp-version-1-18 pgfcore pgffor pgfkeys pgfmath pgfopts pgfrcs pgfsys refcount rerunfilecheck siunitx tikz tikz-uml translations translator trig ulem uniquecounter url xcolor xstring xxcolor
  compiler: latexmk
    engine: -pdf
    options:
      -verbose
      -file-line-error
      -synctex=1
      -interaction=nonstopmode
    callback: 1
    continuous: 1
    executable: latexmk
  viewer: General
  qf method: LaTeX logfile
lervag commented 1 month ago

I use vimtex throug vims package mechanism, and have it in pack/foo/start/vimtex/

Cool. Notice that I personally strongly prefer a plugin manager. For Vim, I've found vim-plug to work very well. But the builtin package mechanism is probably also fine, if you know what you are doing.

I use a dvorak keyboard layout and have remapped some keys, I end up using t instead of j to move down.

now this conflicts with all the nmap from vimtex starting with a t, and everytime I want to move down a line, there is that pesky wait until the cursor moves.

In this case, I would advice the following: Either disable all default mappings and make your own. Use let g:vimtex_mappings_enabled = v:false to disable. See the map targets under :help vimtex-default-mappings for the mappings you want to create.

Or you can use g:vimtex_mappings_prefix to adjust the <localleader>l prefix and then remap the keys you want to override in your personal $vim/ftplugin/tex.vim.

Notice that you should not put it under after/, because VimTeX will avoid creating mappings to <plug>(...) targets that already have a map.

I tried different approaches:

adding nunmap t** to $vim/after/tex.vim

You probably wanted $vim/after/ftplugin/tex.vim; but see my previous comment.

DWIAltonaAnalytics commented 1 month ago

Hi, thank you.

I went with the g:vimtex_mappings_enabled = v:false in my vimrc and added the mappings I was using to my $vim/ftplugin/tex.vim

I can add more if I need them.

DWIAltonaAnalytics commented 1 month ago

fixed.

lervag commented 1 month ago

I think that's a very good approach.