" vimrc: a monolithic vim setup. {{{1 " © 2009-2020 Tom Vincent " vim: set fdm=marker: " Environment {{{1 " A consistent runtime environment. " Forget about vi and set it first as it modifies future behaviour set nocompatible set guicursor= " fallback to terminal's choice set spellfile=$XDG_CONFIG_HOME/nvim/spell/en.utf-8.add set backupdir=$XDG_CONFIG_HOME/nvim/tmp,. set directory=$XDG_CONFIG_HOME/nvim/tmp,. " Load plugins packloadall " General preferences {{{1 " " Learn about these using vim help. " Tabbing set tabstop=2 " The number of spaces a tab is set shiftwidth=2 " Number of spaces to use in auto(indent) set softtabstop=2 " Just to be clear set expandtab " Insert tabs as spaces " Searching set wrapscan " Wrap searches set ignorecase " Ignore search term case... set smartcase " ... unless term contains an uppercase character set hlsearch " ... as you type " Wrapping set textwidth=80 " Hard-wrap text at nth column set nowrap " Don't wrap long lines (good for vsplits) " General set showmode " Persistent notice of current mode set spelllang=en_gb " Speak proper English set encoding=utf-8 " Default encoding set noshowcmd set clipboard=unnamedplus set nomodeline set modelines=0 set ttimeoutlen=0 set guicursor= " Fallback to terminal's choice set shortmess+=c " don't give |ins-completion-menu| messages " Ignore the following globs in file completions set wildignore+=*.o,*.obj,*.pyc,*.so,*.swp,*.zip,*.jpg,*.gif,*.png,*.pdf set wildignore+=.git,.hg,.svn,DS_STORE,bower_components,node_modules " Visuals {{{1 set termguicolors set background=dark colorscheme onedark " Mappings {{{1 " " vim does funny things with inline comments here, so don't use them. " Silently open a shell in the directory of the current file if has("win32") || has("win64") map ,s :silent !start cmd /k cd %:p:h endif " Return to normal mode inoremap jk " Always move between wrapped lines nnoremap j gj nnoremap k gk " Move between splits with CTRL+[hjkl] nnoremap h nnoremap j nnoremap k nnoremap l " Leader keys {{{2 " Map leader (the dedicated user-mapping prefix key) to comma let mapleader = "," let maplocalleader = "," " Leader + v to open vimrc in a new tab nmap v :tabedit $MYVIMRC " Disable search highlighting nnoremap :nohlsearch " Create a directory relative to the current file map d :!mkdir -p %% " pwgen nmap p :read !pwgen -sy1 32 nmap q gqip " Function keys {{{2 " Toggle paste mode (particularly useful to temporarily disable autoindent) set pastetoggle= " Disabled keys {{{2 " Disable arrow keys (force good habits) nnoremap nnoremap nnoremap nnoremap inoremap inoremap inoremap inoremap vnoremap vnoremap vnoremap vnoremap " Disable help key inoremap nnoremap vnoremap " Disable Ex mode nnoremap Q " Autocommands {{{1 if has('autocmd') " detect indentation settings for all files autocmd BufReadPost * :DetectIndent endif autocmd BufWritePost ~/documents/wiki/* call AutoCommit() autocmd BufRead,BufEnter *.js setlocal matchpairs={:},[:] lua << EOF require('lsp') local cmp = require 'cmp' cmp.setup { snippet = { expand = function(args) vim.fn["vsnip#anonymous"](args.body) end, }, mapping = { [''] = 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.Replace, select = true, }, }, sources = { { name = 'nvim_lsp' }, { name = 'vsnip' }, { name = 'path' }, { name = 'buffer' }, }, } require('gitsigns').setup() vim.fn.sign_define("DiagnosticSignError", {text = "✖", texthl = "DiganosticSignError"}) vim.fn.sign_define("DiganosticSignWarning", {text = "⚠", texthl = "DiganosticSignWarning"}) vim.fn.sign_define("DiganosticSignInformation", {text = "𝐢", texthl = "DiganosticSignInformation"}) vim.fn.sign_define("DiganosticSignHint", {text = "•", texthl = "DiganosticSignHint"}) require'nvim-treesitter.configs'.setup { ensure_installed = { "astro", "bash", "css", "dockerfile", "graphql", "html", "ini", "javascript", "json", "lua", "markdown", "markdown_inline", "nix", "terraform", "tsx", "typescript", "vim", "yaml", }, sync_install = false, highlight = { enable = true, additional_vim_regex_highlighting = false, }, indent = { enable = true } } require("lsp_signature").setup({ hint_enable = false }) EOF set foldmethod=expr set foldexpr=nvim_treesitter#foldexpr()