personal-page/_master_wiki/notes/Neovim.md

4.5 KiB

Config

Formatters

Hay que añadirlos en plugins/formatters.lua, pueden ser instalados con mason.

Linters

Hay que añadirlos en plugins/linters.lua, pueden ser instalados con mason.

LSP

Hay que añadirlos en plugins/lsp.lua, son instalados automáticamente al ser agregados aquí con mason.

Remember to use:

Misc

  • In visual mode, you can use J or K to move the selection
  • With alt + hjkl I can resize the window, I can restore the size with <C-w> =
  • <Leader>r tiene keymaps para search and replace

LSP y code actions

  • <Leader>la -> Code action by lsp
  • <Leader>lA -> Node action by Treesitter
  • <Leader>lm -> Toggle node join split (arrays, objects, etc)
  • <Leader>lr -> rename symbol
  • <Leader>fd -> See disagnostics in file
  • <Leader>fD -> See disagnostics in workspace
  • gr -> List reference of symbol in telescope

Git

Puedo invocar comandos de git directamente desde neovim con :Git ...

Harpoon

Fast navigation with <Leader><Leader>[hjkl]

Buffers

Puedo hacer pin a ciertos buffers para no cerrarlos con <Leader>bp y cerrar todos los buffers no pineados con <Leader>bP

Puedo cerrar los otros buffers no activos con <Leader>bO

Treesitter

TODO: Research movemet with Treesitter

Text objects

Los text objects se utilizan en la forma de ==acción - motion==, Ej: vi{ es selecciona dentro de los { }

Acciones:

  • v -> visual selection
  • d -> delete
  • c -> change
  • gc -> comment

Text objects available:

  • f -> function
  • t -> html tag

Surround plugin

  • Actions (all of them are dot-repeatable out of the box and respect v:count for searching surrounding) with configurable keymappings:
    • Add surrounding with sa (in visual mode or on motion).
    • Delete surrounding with sd.
    • Replace surrounding with sr.
    • Find surrounding with sf or sF (move cursor right or left).
    • Highlight surrounding with sh.
    • Change number of neighbor lines with sn (see |MiniSurround-algorithm|).
  • Surrounding is identified by a single character as both "input" (in delete and replace start, find, and highlight) and "output" (in add and replace end):
    • 'f' - function call (string of alphanumeric symbols or '_' or '.' followed by balanced '()'). In "input" finds function call, in "output" prompts user to enter function name.
    • 't' - tag. In "input" finds tag with same identifier, in "output" prompts user to enter tag name.
    • All symbols in brackets '()', '[]', '{}', '<>". In "input' represents balanced brackets (open - with whitespace pad, close - without), in "output" - left and right parts of brackets.
    • '?' - interactive. Prompts user to enter left and right parts.
    • All other alphanumeric, punctuation, or space characters represent surrounding with identical left and right parts.

Text Object

works for:

  • Comments (gc)
  • Visual selection

Telescope

Browser plugins mappigns:

Insert / Normal fb_actions Description
<A-c>/c create Create file/folder at current path (trailing path separator creates folder)
<S-CR> create_from_prompt Create and open file/folder from prompt (trailing path separator creates folder)
<A-r>/r rename Rename multi-selected files/folders
<A-m>/m move Move multi-selected files/folders to current path
<A-y>/y copy Copy (multi-)selected files/folders to current path
<A-d>/d remove Delete (multi-)selected files/folders
<C-o>/o open Open file/folder with default system application
<C-g>/g goto_parent_dir Go to parent directory
<C-e>/e goto_home_dir Go to home directory
<C-w>/w goto_cwd Go to current working directory (cwd)
<C-t>/t change_cwd Change nvim's cwd to selected folder/file(parent)
<C-f>/f toggle_browser Toggle between file and folder browser
<C-h>/h toggle_hidden Toggle hidden files/folders
<C-s>/s toggle_all Toggle all entries ignoring ./ and ../
<Tab> see telescope.nvim Toggle selection and move to next selection
<S-Tab> see telescope.nvim Toggle selection and move to prev selection
<bs>/ backspace With an empty prompt, goes to parent dir. Otherwise acts normally

Plugins compatibility errors

Lazy.nvim tiene un lazy-lock.json, por lo que ante cualquier problema de compatibilidad, podemos volver a versión especificada aqui con Lazy restore. Es importante mantener este archivo en git y solo modificarlo cuando se esté seguro que no hay problemas de compatibilidad.