Skip to content

klebster2/vimrc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

klebster2's neovim configuration

Table of Contents


Setup

Ubuntu installation

1. Install the packages jq, curl, and npm

You can do this via apt, apt-get, snap or a package manager of your choosing. Note: A package manager is usually dependent on your operating system. apt, apt-get, snap are automatically installed to Ubuntu.

  • jq For querying json files.
  • curl For downloading installation files and plenary.nvim
  • npm (node package manager)

To install all the above dependencies run:

apt-get install jq curl -y
# Install node / node package manager - npm
curl -fsSL https://fnm.vercel.app/install | bash && . ~/.bashrc && fnm use --install-if-missing 20

2. Install neovim

You can use the following shell script.

curl -LO "https://github.com/neovim/neovim/releases/latest/download/nvim.appimage"
chgrp sudo nvim.appimage
chmod ugo+x nvim.appimage
./nvim.appimage --appimage-extract
./squashfs-root/AppRun --version
mv squashfs-root / 2> /dev/null || sudo mv squashfs-root /
ln -s /squashfs-root/AppRun /usr/bin/nvim 2> /dev/null || sudo ln -s /squashfs-root/AppRun /usr/bin/nvim
nvim --version

3. Clone the repo, and run the install.sh shell script.

Clone the repo to ~/.config/nvim (the default neovim location)

mkdir -pv ~/.config && git clone "https://github.com/klebster2/vimrc" ~/.config/nvim

Run the installation script install.sh

pushd ~/.config/nvim && ./install.sh && popd

4. Install Ollama (optional)

Ollama is useful for generative AI applications.

One of the use cases is to generate code candidates using the neovim package: ollama.nvim

curl -fsSL https://ollama.com/install.sh | sh

Check your GPU Virtual RAM (VRAM) can hold a model defined in ollama.lua, under opts.model

5. That's it for now.

Enjoy your neovim experience!

Usage notes

Configuration Commands

The following section lists commands that will take you to configuration files.

Use:

  • <leader>ev to edit the init.lua file - this is the main configuration file (at the location ~/.config/nvim/init.lua ) in this repository find it here: init.lua

Some of the mappings listed below can be found within the following keymapping files:

To go to either one of the two keymappings.lua files, when in normal mode, use:

  • <leader>em to go to lua/keymappings.lua (the basic set of mappings that should work with native neovim).

If you are unsure what a 'leader' key is, first read this: Learn Vimscript the Hard Way - Chapter 06 - Leaders

Useful commands

Note that the following commands apply to Normal Mode only.

  • Use gd for Go to the Definition.

    • When the Cursor is on a Word (cword), and that word is a function-call, or variable, you can type gd to go to the function Definition.
  • Use gf for Go to the File.

    • When the Cursor is on a File (fullpath, or partial path), you can type gf to Go to the File.
  • To exit insert mode use jk typing them together quickly. Note that the default way to exit normal mode in vi, vim and neovim is <ESC>, but <ESC> won't work because in this configuration, because it has been unmapped.

To jump to a configuration file (these will only work if you have a configuration file at that location), use:

  • <leader>et for Edit Tmux, to edit the tmux configuration file: ~/.tmux.conf

  • <leader>eb for Edit Bash, to edit the bashrc file ~/.bashrc

  • <leader>ei for Edit Inputrc, to edit the inputrc file ~/.inputrc

Completion menu for LSP and CMP

Note that this applies to Insert Mode completions only, and especially when the cmp popup menu is visible.

Nvim-Cmp is an autocompletion engine.

LspConfig is a NeoVim client that allows for configuring (Language-Server-Protocols in NeoVim)

To jump to the subsequent completions using Lsp, Cmp, Luasnip, etc. use

  • <CTRL+p> for Prev
  • <CTRL+n> for Next

Use

  • <CTRL+e> to Exit
  • <CTRL+y> to say Yes, the user wants to complete the text with the current option; confirm and insert the completion
  • <CR> to Accept the completion, replacing everying that was previously there

Completion Docs

Note that this applies to Insert Mode only (as above).

  • <CTRL-f> to scroll the docs Forwards
  • <CTRL-b> to scroll the docs Backwards

Also see :help vim.lsp.* for documentation on any of the LSP functions

Language Server Protocol (LSP) Diagnostics

Note that this applies to Normal Mode only.

Use:

  • <SPACE>+e to open a floating window containing the LSP diagnostic (according to the LSP)
  • <SPACE>+q to open a window of LSP diagnostics below the current buffer
  • [d to go to the previous LSP diagnostic
  • ]d to go to the next LSP diagnostic

Also see :help vim.diagnostic.* for documentation on any of the Lsp diagnostics.

To see the configuration, go to the file lua/plugins/nvim-cmp-cfg.lua.

LuaSnip

LuaSnip is a snippets engine, that permits the user to use snippet templates. These templates should ideally increase the speed of development while not sacrificing code quality.

When completing a snippet, use

  • <CTRL+k> after selecting a luasnip option to jump to the next snippet jump point
  • <CTRL+j> to jump to the previous snippet jump point

See the snippets file here: lua/plugins/snippets.lua

NvimTree

NvimTree is a plugin used for file / directory viewing.

To active the NvimTree view, use <leader>vs, with the default settings this is <space>vs. When within the NvimTree viewer, you can use any of the defaults:

  • <SHIFT+r> to Reread the files contained in the focused project
  • <SHIFT+h> to toggle the display of hidden files and folders beginning with a dot .. Note that some other files may be hidden by default (like git files / directories).
  • <SHIFT+e> to Expand the entire file tree starting from the root folder (workspace)
  • <f> to Find files (opening a search filter that will be applied)
  • <SHIFT+w> To collapse all open folders starting from the root folder
  • <\s> to open the file with the System application set by default for that file type
  • <-> (Dash/Hyphen) Allows you to go "backwards" into parent folders. This navigation also allows you to exit the root folder (workspace) to your home directory
  • <SHIFT+f> to close the interactive search
  • <CTRL+k> to display information about the file such as size, creation date, etc.
  • <g+?> to open the help with all the predefined shortcuts for quick reference
  • <q> to close the file explorer

For the NvimTree configuration, go to lua/plugins/nvim-tree.lua

Also note that some files and directories such as .git/, and .gitignore may be omitted from the NvimTree view due to how unusual it is for those files to be edited.

Fzf-Lua

Fzf is a powerful fuzzy-finder. It can be used to quickly find files using keybindings in the terminal such as <Ctrl+r> for history.

Since the release of one of Fzf's cousins fzf.vim, a github user wrote an Fzf-Lua plugin which is blazingly fast. Allegedly, it is even faster than Telescope.

Use:

  • <CTRL-f> to start searching for files.
  • <CTRL-t> to search helptags
  • <CTRL-x> to grep the cword (word under the cursor)

Nvim Spell

Use:

  • <z>+<w> to add the cword to the dictionary.
  • <leader>ss to :set spell (misspelled words will appear underlined)

Releases

No releases published

Packages

No packages published