nvim
vim is nice because of its ubiquity on terminals. However, if you have the ability to perform installs and you spend a lot of time on the machine, then it may be worth getting to know nvim.
Here are some notes on using and setting up a fairly nice system.
Use
autocomplete
- when you have an autocomplete option:
ctrl + enter- do not autocomplete and instead go to next lineenterorctrl + y- use autocomplete optionC-pandC-n- go to previous/next autocomplete optiontab- does nothing!
folding
za- toggle fold at cursor
TODO: figure out how to do smart folding on a markdown document
help
Run :help in nvim to go to the guide. Where applicable, the help guide section will be listed to allow easily finding more information.
Setup
plugin management with Packer
Go to packer.lua.
:so
:PackerSyncUseful Plugins
treesitter
This is a parser that builds a syntax tree for a file as you edit it. This usually provides a faster and more accurate syntax highlighter than techniques using regex.
Nice writeup on uses here.
I have c, lua, vim, help, rust, js, python and scala installed, but it can find others on the fly.
telescope
This is a code fuzzy finder.
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>pf', builtin.find_files, {})
vim.keymap.set('n', '<C-p>', builtin.git_files, {})
vim.keymap.set('n', '<leader>ps', function()
builtin.grep_string({ search = vim.fn.input("Grep > ") });
end)undotree
harpoon
Fugitive
Allows you to do git stuff without leaving nvim.
Giving this a leader shortcut makes it easier to use.
-- after/plugins/fugitive
vim.keymap.set("n", "<leader>gs", vim.cmd.Git);Then <leader>gs followed by commit allows you to perform a git commit.
lsp
This is how you enable language-specific autocompletion.
Lua functions
:lua FunctionName()Configuration Structure
lua-guide-config
- Everything should be in
~/.config/nvim. - The base file is
init.lua. - Anything in
plugin/will run on startup ifplugin/is inruntimepath, the directory where nvim looks for stuff. - These are specially designated to be searched for and ran first:
filetype.luafiletypes |new-filetype|autoload/automatically loaded scripts |autoload-functions|colors/color scheme files |:colorscheme|compiler/compiler files |:compiler|doc/documentation |write-local-help|ftplugin/filetype plugins |write-filetype-plugin|indent/indent scripts |indent-expression|keymap/key mapping files |mbyte-keymap|lang/menu translations |:menutrans|lua/|Lua| pluginsmenu.vimGUI menus |menu.vim|pack/packages |:packadd|parser/|treesitter| syntax parsersplugin/plugin scripts |write-plugin|query/|treesitter| queriesrplugin/|remote-plugin| scriptsspell/spell checking files |spell|syntax/syntax files |mysyntaxfile|tutor/tutorial files |:Tutor|
- then
after/is searched (seeafter-directory)
Issues
Error for treesitter and lua
Error executing lua callback: ...-linux64/share/nvim/runtime/lua/vim/treesitter/query.lua:219:
query: invalid node type at position 3406 for language lua stack traceback:
:TSUpdate
> -linux64/share/nvim/runtime/lua/vim/treesitter/query.lua:219: query: invalid node type at position 3406 for language lua"
Tree-sitter was having issues. :TSUpdate did not help.
Ended up having to delete the tree-sitter folder in: ~/.local/share/nvim/