neovim-config/README.md

9.3 KiB

The config is complete but still work in progress as I am new to lua and slowly learning vim stuffs. I'll keep adding new features like snippets etc and clean the config , make neovim (cli version) as functional as an IDE while being eyecandy. Pull requests are welcome.

Screenshots -



Very Useful lua plugins used in my config -

lspkind-nvim

This tiny plugin adds vscode-like pictograms to neovim built-in lsp completion items :


nvim-tree.lua

fast file tree :


telescope-nvim -

A fuzzy file finder, picker, sorter, previewer and much more:


indent-blankline.nvim -

adds indentline :

using indenLine plugin on left and blanklineNvim on right

galaxyline -

fastest statusline plugin I've used so far:


gitsigns.nvim -

Shows git signs of a repo on the signcolumn to indicate diffs/changes etc (needs plenary.nvim)


nvim-bufferline.lua -

As a top bufferline like thing which lets me handle tabs like switching, closing tabs.


nvim-web-devicons -

Lua fork of vim devicons which lets me change icons of filetypes


nvim-treesitter

Better syntax highlighting for programming languages ( my config just has html,css,js support for now ).

without / with Treesitter :

nvim-base16 -

contains a collection of all base16 themes for vim , plugin written in lua (comparison of base16-vim and nvim-base16):

nvim-base16 doesnt even take time to load unlike base16-vim which was eating half of the loadup time! ( the below screenshot was taken and tested on my old pentium laptop , so results might differ)


(neovim loads pretty fast on ssds)


Config structure

     nvim
      ├──init.lua
      └──lua
          └──anything.lua
  • The init.lua is used instead of init.vim.
  • The lua folder contains modules ( config files ) , in the example above anything.lua file in lua folder could be considered as a module.
  • The anything.lua file is supposed to have any neovim config written in lua , its like splitting the overall config into small bits and make it more organized , like one module for highlights and colors , another one for statusline and so on!.
  • To load or source that "anything" module (like making it load with init.lua ) ,add this is in init.lua : require "anything".

Features

  • File navigation with Nvimtree
  • mouse works
  • managing tabs with bufferline
  • autosave
  • icons on nvimtree , telescope , bufferline/statusline and almost everywhere! with nvim-web-devicons
  • minimal status line ( galaxyline)
  • gitsigns (colored bars in my config)
  • using nvim-lsp
  • nvim-lspconfig for nvim-lps configuration
  • nvim-compe for autocompletion
  • lspkind to show pictograms on autocompletion items
  • telescope for file finding , picking , previewing (files and even images)
  • nvim-treesitter for syntax highlighting
  • nvim-autopairs , for autolosing braces and stuffs
  • neoformat for prettifying / formatting code
  • packer.nvim as package manager
  • indent-blankline.Nvim for indentlines
  • smooth scrolling
  • Snip support from VSCode through vsnip supporting custom and predefined snips (friendly-snippets)

Guides to migrate your nvim configs to init.lua -

Clone my setup -

  • Install neovim-nightly , also use a nerdfont on your terminal.

  • Use these colors for your terminal , Its in xresources format so it'd would be easier to use a terminal that supports xresources like st , urxvt , xterm , My st build.

  • run the install.sh (this might work only on nix systems),this opens neovim (press enter or y to skip the errors , the errors will only show once).

  • Install ripgrep , fd , ueberzug for telescope media extension to work.

  • Manual installation , incase the install.sh doesnt work for you :

  • Install packer.nvim


git clone https://github.com/wbthomason/packer.nvim\
 ~/.local/share/nvim/site/pack/packer/start/packer.nvim

  • copy lua folder and init.lua into ~/.config/nvim
  • Open neovim and install all plugins , :PackerInstall (let treesitter install all its extensionsm
  • Install language servers and prettier ( for autocompletion etc and code formatting , nodejs should be installed too!) , this usually depends on the language support you want to add in your neovim config.
npm config set prefix=~/.node_modules
npm install -g vscode-html-languageserver-bin typescript typescript-language-server  vscode-css-languageserver-bin prettier

(ADD ~/.node_modules at your PATH)

To setup any language server , follow this guide https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md and search up the needed LSP. For example if I needed clangd's lsp server :

I'd install it first and add its setup line : `` -- in /lua/nvim-lspconfig/lua.lua file

   require'lspconfig'.clangd.setup{}  ``

Default Mappings

space is the leader key.

  • Opening terminals!

  • Ctrl l Open terminal vertically over right

  • Ctrl x Open terminal horizontally below the current window

  • File tree (nvim-tree)

  • Ctrl n toggle neovim tree

  • Shift h show hidden files (use these keybinds when cursor's in the filetree, same for the keybinds below).

  • Ctrl + v open files in vertical split

  • Ctrl + x open files in horizontal split

  • Toggling stuffs

  • leader + n toggle line number

  • leader + z toggle truezen.nvim's Ataraxis mode

  • leader + m toggle truezen.nvim's minimalistic mode

  • Copy text

  • Ctrl a copies everything in the current file

  • select any text + y copies the selected text

  • Telescope

  • leader + f b open all buffers

  • leader + f f find files in the current DIR

  • leader + f o open recently edited files

  • leader + f h opens up a help page like thing

  • Ctrl + v open files in vertical split

  • Ctrl + x open files in horizontal split

  • Formatting code

  • leader + f m formats or beautifies the code in current window via neoformat (currently only html ,css , js can be formatted . To be able to use this keybind you need to install the formatter locally for your language , in my case prettier was required only so I installed it. check (this)[https://github.com/sbdchd/neoformat].

  • Neoscroll

  • <C-u>, <C-d>, <C-b>, <C-f>, <C-y> and <C-e> : Smooth scrolling for window movement commands.

  • Managing tabs with bufferline!

  • TAB or Shift TAB cycle through opened tabs

  • Shift x close current tab

  • Shift t open new tab

Nvim-lspconfig (major ones)

  • K hover and show the definition
  • gd jumps to the definition (works for user and language definitions)
  • [d jumps to the previous error
  • ]d jumps to the next error
  • leader D jumps to the definition
  • leader w + q list all the errors in a new buffer
  • leader r + n rename all instances of this definition (user functions and declaration)

TODO

  • Make the statusline more elegant.
  • Add more themes.

Contact -

  • My linux / unix related ricing community: https://t.me/DE_WM (telegram)
  • Me: @siduck (telegram)