" Yet another .vimrc (YAVR) " Ben Simmonds (2007) " See :options for further details. " " ▄▄▄▄· • ▌ ▄ ·. .▄▄ " ▐█ ▀█▪·██ ▐███▪▐█ ▀. " ▐█▀▀█▄▐█ ▌▐▌▐█·▄▀▀▀█▄ " ██▄▪▐███ ██▌▐█▌▐█▄▪▐█ " ·▀▀▀▀ ▀▀ █▪▀▀▀ ▀▀▀▀ """""""""""""""""""""""""""""""""""""""""""""""""""""" " PLUGINS """""""""""""""""""""""""""""""""""""""""""""""""""""" call plug#begin('~/.config/nvim/plugged') " general enhancements Plug 'ntpeters/vim-better-whitespace' "trailing whitespace Plug 'justinmk/vim-sneak' "precise motioning Plug 'editorconfig/editorconfig-vim' "cross editor coding styles Plug 'tpope/vim-surround' "wrap text Plug 'tpope/vim-commentary' "smart commenter Plug 'mcchrish/nnn.vim' "file explorer Plug 'sbdchd/neoformat' "code formatter "Plug 'jiangmiao/auto-pairs' "auto clode brackets "Plug 'nvim-lua/popup.nvim' "popup api " gui enhancements Plug 'morhetz/gruvbox' "colorscheme Plug 'machakann/vim-highlightedyank' "pop yanks Plug 'andymass/vim-matchup' "extends % lang aware Plug 'ap/vim-css-color' "colorise hashcodes Plug 'ryanoasis/vim-devicons' "file type icons " fuzzy finder Plug 'nvim-telescope/telescope.nvim' "fuzzy finder Plug 'nvim-lua/plenary.nvim' "for telescope " git Plug 'airblade/vim-rooter' "changes working dir to project root Plug 'mhinz/vim-signify' "git gutter Plug 'tpope/vim-fugitive' "git integration " syntactic language supports Plug 'rust-lang/rust.vim' "Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } Plug 'cespare/vim-toml' Plug 'stephpy/vim-yaml' Plug 'godlygeek/tabular' Plug 'plasticboy/vim-markdown' " semantic language support (sharksforarms/neovim-rust) Plug 'neovim/nvim-lspconfig' "common lsp configs Plug 'hrsh7th/nvim-cmp' "autocompletion framework Plug 'hrsh7th/cmp-nvim-lsp' "cmp lsp completion Plug 'hrsh7th/cmp-buffer' "cmp editor completion Plug 'hrsh7th/cmp-path' "cmp path completion Plug 'hrsh7th/cmp-cmdline' "cmp cmdline completion Plug 'hrsh7th/cmp-vsnip' "cmp snippet completion Plug 'hrsh7th/vim-vsnip' "snippet engine Plug 'simrat39/rust-tools.nvim' "extra functionality over rust analyzer call plug#end() """""""""""""""""""""""""""""""""""""""""""""""""""""" " GENERAL """""""""""""""""""""""""""""""""""""""""""""""""""""" set nocompatible "drop some legacy compatibility in favour of new things filetype on "file specific goodness filetype plugin on filetype indent on set autoread "refresh file contents when modified externally set autochdir "use the current file as working dir set autowrite "auto write file if call make set backspace=indent,eol,start "specifies what can do in Insert mode set colorcolumn=80 "visual ruler set cursorline "highlight the screen line of the cursor set encoding=utf-8 "character encoding to be used in Vim set fileencoding=utf-8 "character encoding to be used by current file set gdefault "use the 'g' (global) flag for :substitute by default set nohlsearch "highlight search results set hidden "dont unload a buffer when no longer shown in a window set ignorecase "ignore case when searching set incsearch "show match for partly typed search command set list "show non-vis characters set listchars=tab:▸\ ,eol:¬,nbsp:⋅,trail:⋅ "representation of non-vis chars let g:mapleader=',' "remap leader key to , set number "show line numbers "set paste "disabled because resets expandtab (spaces not tabs) set relativenumber "make line numbering relative to the current line set shell=/bin/bash "default shell set showmatch "when inserting a bracket, briefly jump to its match set smartcase "override 'ignorecase' when pattern has upper case characters set laststatus=2 "2 = always show a status line for vim-airline set novisualbell "don't use a visual bell instead of beeping set winheight=5 "minimal number of lines used for the current window set winminheight=5 "minimal number of lines used for any window set winwidth=84 "minimal number of columns used for the current window set wildmode=list:longest "activate auto-completion for file paths set wildignore+=*.a,*.o set wildignore+=*.bmp,*.gif,*.ico,*.jpg,*.png set wildignore+=.git,.svn,.hg set wildignore+=*~,*.swp,*.tmp set wildignore+=**/node_modules/* """""""""""""""""""""""""""""""""""""""""""""""""""""" " TEXT, TABS AND INDENTS """""""""""""""""""""""""""""""""""""""""""""""""""""" set expandtab "expand to spaces in Insert mode set tabstop=4 "number of spaces a in the text stands for set softtabstop=4 "number of spaces to insert for a set shiftwidth=4 "number of spaces used for each step of (auto)indent set autoindent "automatically set the indent of a new line set smartindent "do clever autoindenting set wrap "wrap long lines """""""""""""""""""""""""""""""""""""""""""""""""""""" " FILES, BACKUPS AND UNDOS """""""""""""""""""""""""""""""""""""""""""""""""""""" set noswapfile "don't use a swap file for this buffer set nobackup "don't write a backup file before overwriting a file set nowb "don't write a backup file before overwriting a file """""""""""""""""""""""""""""""""""""""""""""""""""""" " COLORS AND FONTS """""""""""""""""""""""""""""""""""""""""""""""""""""" "set background=dark "editor theme "set termguicolors "enable true color syntax enable "syntax highlighting colorscheme gruvbox "default color scheme set t_Co=256 "the number of colors the terminal supports let $TERM="st-256color" "set term=st-256color "what terminal type to use """""""""""""""""""""""""""""""""""""""""""""""""""""" " EXPLICIT FILE TYPING """""""""""""""""""""""""""""""""""""""""""""""""""""" au BufNewFile,BufRead *.adoc set filetype=asciidoc """""""""""""""""""""""""""""""""""""""""""""""""""""" " KEYBOARD MAPPINGS """""""""""""""""""""""""""""""""""""""""""""""""""""" " never arrows in vim, break the addiction today! noremap noremap noremap noremap inoremap inoremap inoremap inoremap " elevated save cmap w!! w !sudo tee % " insert timestamp nmap d i=strftime("%Y-%m-%d %H:%M:%S+11:00") imap d =strftime("%Y-%m-%d %H:%M:%S+11:00") """""""""""""""""""""""""""""""""""""""""""""""""""""" " ▄▄▄·▄▄▌ ▄• ▄▌ ▄▄ • ▪ ▐ ▄ .▄▄ · " ▐█ ▄███• █▪██▌▐█ ▀ ▪██ •█▌▐█▐█ ▀. " ██▀·██▪ █▌▐█▌▄█ ▀█▄▐█·▐█▐▐▌▄▀▀▀█▄ " ▐█▪·•▐█▌▐▌▐█▄█▌▐█▄▪▐█▐█▌██▐█▌▐█▄▪▐█ " .▀ .▀▀▀ ▀▀▀ ·▀▀▀▀ ▀▀▀▀▀ █▪ ▀▀▀▀ """""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""" " TELESCOPE """""""""""""""""""""""""""""""""""""""""""""""""""""" nnoremap ff Telescope find_files nnoremap fg Telescope live_grep nnoremap fb Telescope buffers nnoremap fh Telescope help_tags """""""""""""""""""""""""""""""""""""""""""""""""""""" " NNN.VIM """""""""""""""""""""""""""""""""""""""""""""""""""""" let g:nnn#layout = { 'window': { 'width': 0.9, 'height': 0.6, 'highlight': 'Debug' } } """""""""""""""""""""""""""""""""""""""""""""""""""""" " LSPCONFIG """""""""""""""""""""""""""""""""""""""""""""""""""""" lua << EOF require'lspconfig'.pyright.setup{} require'lspconfig'.rls.setup{} -- require'lspconfig'.rls.setup{ -- settings = { -- rust = { -- unstable_features = true, -- build_on_save = false, -- all_features = true, -- }, -- }, -- } EOF """""""""""""""""""""""""""""""""""""""""""""""""""""" " RUST-TOOLS """""""""""""""""""""""""""""""""""""""""""""""""""""" " source: sharksforarms/neovim-rust " Configure LSP through rust-tools.nvim plugin. " rust-tools will configure and enable certain LSP features for us. " See https://github.com/simrat39/rust-tools.nvim#configuration lua < lua vim.lsp.buf.definition() nnoremap K lua vim.lsp.buf.hover() nnoremap gD lua vim.lsp.buf.implementation() nnoremap lua vim.lsp.buf.signature_help() nnoremap 1gD lua vim.lsp.buf.type_definition() nnoremap gr lua vim.lsp.buf.references() nnoremap g0 lua vim.lsp.buf.document_symbol() nnoremap gW lua vim.lsp.buf.workspace_symbol() nnoremap gd lua vim.lsp.buf.definition() " quick-fix nnoremap ga lua vim.lsp.buf.code_action() """""""""""""""""""""""""""""""""""""""""""""""""""""" " NVIM-CMP (AUTOCOMPLETION) """""""""""""""""""""""""""""""""""""""""""""""""""""" " source: sharksforarms/neovim-rust " Set completeopt to have a better completion experience :help completeopt " menuone: popup even when there's only one match " noinsert: Do not insert text until a selection is made " noselect: Do not select, force user to select one from the menu set completeopt=menuone,noinsert,noselect " Avoid showing extra messages when using completion set shortmess+=c " Setup Completion " See https://github.com/hrsh7th/nvim-cmp#basic-configuration lua <'] = cmp.mapping.select_prev_item(), [''] = cmp.mapping.select_next_item(), -- Add tab support [''] = cmp.mapping.select_prev_item(), [''] = cmp.mapping.select_next_item(), [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.complete(), [''] = cmp.mapping.close(), [''] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true, }) }, -- Installed sources sources = { { name = 'nvim_lsp' }, { name = 'vsnip' }, { name = 'path' }, { name = 'buffer' }, }, }) EOF " have a fixed column for the diagnostics to appear in " this removes the jitter when warnings/errors flow in set signcolumn=yes " Set updatetime for CursorHold " 300ms of no cursor movement to trigger CursorHold set updatetime=300 " Show diagnostic popup on cursor hover autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false }) " Goto previous/next diagnostic warning/error nnoremap g[ lua vim.diagnostic.goto_prev() nnoremap g] lua vim.diagnostic.goto_next() """""""""""""""""""""""""""""""""""""""""""""""""""""" " Neoformat """""""""""""""""""""""""""""""""""""""""""""""""""""" let g:neoformat_enabled_python = ['autopep8', 'yapf', 'docformatter'] nnoremap p Neoformat """""""""""""""""""""""""""""""""""""""""""""""""""""" " vim-sneak """""""""""""""""""""""""""""""""""""""""""""""""""""" map f Sneak_s map F Sneak_S