diff options
Diffstat (limited to 'vim/vimrc')
-rw-r--r-- | vim/vimrc | 722 |
1 files changed, 316 insertions, 406 deletions
@@ -1,261 +1,219 @@ -"Fark all from https://jamesdixon.dev/posts/a-minimal-vimrc/ +" Setup {{{ set nocompatible - -if filereadable(expand('$VIMRUNTIME/defaults.vim')) - unlet! g:skip_defaults_vim - source $VIMRUNTIME/defaults.vim -endif -" -" -" leader +filetype indent on +filetype plugin on +" syntax on +runtime macros/matchit.vim "allows jumping between brackets with % in normal mode +" }}} +" Leaders {{{ let maplocalleader = "\\" let mapleader = "," - -" encryption method when using :X -set cm=blowfish2 - -" Source this file again. -noremap <silent> <localleader>rc :source ~/.vim/vimrc<CR> -" -" Underline the current line, based on its length. -noremap <silent> <leader>ul mmyypVr-<Esc>`m -" -" Show the 'list' characters. -noremap <silent> <leader>ls :set list!<CR> -" -" Remove double- or single-quotes, or graves wrapped around a string. -noremap <silent> <leader>rdq mmF"xf"x`m -noremap <silent> <leader>rsq mmF'xf'x`m -noremap <silent> <leader>rg mmF`xf`x`m - -" Jump up or down by 10 lines. -noremap <silent> J 10j -noremap <silent> K 10k - - +nnoremap <silent> <leader>idate :.!date +"\%F"<CR>Ea<space> +nnoremap <leader>q :call TaskWarriorAddCurrentLine()<CR> +" nnoremap <C-h> :tabprevious<cr> +" nnoremap <C-l> :tabnext<cr> +" switch between tabs.... +nnoremap <tab> gt +" pandoc command to generate weekly plan page in Firefox (or not, if we just +" wish to refresh) +nnoremap <leader>w :!pandoc /home/lemon/Documents/Notes/MOD/Projects/weekly_planning.md --css /home/lemon/.local/share/pandoc/templates/mystyles.css -s -o /tmp/toss.html; firefox /tmp/toss.html &<cr> +nnoremap <leader>W :!pandoc /home/lemon/Documents/Notes/MOD/Projects/weekly_planning.md --css /home/lemon/.local/share/pandoc/templates/mystyles.css -s -o /tmp/toss.html<cr> +" Open vimrc +nnoremap <leader>ev <C-w>s<C-w>j<C-w>L:e $HOME/.vim/vimrc<cr> " Place timestamps, be it date (YYYY-MM-DD) or time (HH:MM:SS). if (exists("*strftime")) noremap <silent> <leader>date "=strftime("%F")<CR>p9h noremap <silent> <leader>time "=strftime("%X")<CR>p7h endif -" -" Execute the current line with BASH. -noremap <silent> <leader>rl :.w !bash<CR> -" Run the current file with PERL, Python, BASH, or a Bourne Shell derivative. -noremap <silent> <leader>rpl :!clear; perl %<CR> -noremap <silent> <leader>rpy :!clear; python %<CR> -noremap <silent> <leader>rb :!clear; bash %<CR> -noremap <silent> <leader>rs :!clear; sh %<CR> - -" Disable arrow keys for normal mode. -noremap <up> <Nop> -noremap <down> <Nop> -noremap <left> <Nop> -noremap <right> <Nop> - -" Disable arrow keys for insert mode. -inoremap <up> <Nop> -inoremap <down> <Nop> -inoremap <left> <Nop> -inoremap <right> <Nop> - -" Disable arrow keys for visual mode. -vnoremap <up> <Nop> -vnoremap <down> <Nop> -vnoremap <left> <Nop> -vnoremap <right> <Nop> - -" Disable arrow keys for command mode. -cnoremap <up> <Nop> -cnoremap <down> <Nop> -cnoremap <left> <Nop> -cnoremap <right> <Nop> - -" this needs to be here when using vim native package manager: -" https://github.com/dracula/vim/issues/161 -"packadd! dracula | colorscheme dracula - -" ignore wrapping. you can move to the visual start of end of a line with `g0` -" and `g$`, respectively. -noremap j gj -noremap k gk -" - -" These do strange things to centering of text, etc. -"set sidescrolloff=999 -"set scrolloff=999 - -set shell=/bin/sh -set hi=500 -set novisualbell -set nonumber "show line numbers -set wildmenu "enable a menu that shows tab completion options in the status bar -set wildchar=<TAB> -set showmatch "highlights matching brackets on cursor hover -set ruler "show cursor position in status bar -set showcmd "shows the normal mode command before it gets executed +" Place timestamps, be it date (YYYY-MM-DD) or time (HH:MM:SS). +if (exists("*strftime")) + noremap <silent> <leader>date "=strftime("%F")<CR>p9h + noremap <silent> <leader>time "=strftime("%X")<CR>p7h +endif +" Generate ctags for current working directory +nnoremap <leader>tt :silent !ctags -R . <CR>:redraw!<CR> +" notes stuff - from https://www.edwinwenink.xyz/posts/43-notes_tagging/ +" Go to index of notes and set working directory to my notes +nnoremap <leader>ni :e $NOTES_DIR/index.md<CR>:cd $NOTES_DIR<CR> +" related to https://oleksii.shmalko.com/2014/using-vim-as-c-cpp-ide/ +" to enable putting a config file in the proejct directory +" clear search highlights +nnoremap <leader><space> :noh<cr>:call clearmatches()<cr> +nnoremap <leader><C-p> :<C-u>FZF!<CR> +nnoremap <C-p>p :Files<CR> +nnoremap <C-p>g :GitFiles<CR> +nnoremap <leader>o :Tags<CR> +nnoremap <leader>h :History<CR> +nnoremap <silent> <leader>0 :Files<CR> +nnoremap <silent> <leader>; :BLines<CR> +nnoremap <silent> <leader>l :Lines<CR> +nnoremap <silent> <leader>o :BTags<CR> +nnoremap <C-p>b :Buffers<CR> +nnoremap <silent> <leader>? :History:<CR> +nnoremap <silent> <leader>/ :execute 'Ag ' . input('Ag/')<CR> +nnoremap <silent> <leader>ft :Filetypes<CR> +nnoremap <silent> <leader>CC :Commands<CR> +" Open quickfix list in a right vertical split (good for Ngrep results) +command! Vlist botright vertical copen | vertical resize 50 +nnoremap <leader>v : Vlist<CR> +" }}} +" Options {{{ +set clipboard=unnamed,unnamedplus " just past in with out needing "* +set autoread +set backspace=indent,eol,start +set exrc +set cuc +set secure +set scrolloff=1 +set history=799 set encoding=utf-8 -set fileformats=unix,dos,mac -set nohlsearch "highlights searches -set incsearch "incremental search (searches character by character) -set ignorecase "ignores the case of a search -set smartcase "only ignores case if there are no capital letters in search (only works after ignorecase has been set) -set tabstop=4 "the amount of spaces that vim will equate to a tab character -set softtabstop=4 "like tabstop, but for editing operations (insert mode) -set splitbelow " split horiz below +set wrap +set wrapmargin=0 +set wildignore=**/__pycache*/** +set wildoptions=pum +set wildmenu +set wildchar=<TAB> +set showmatch +set ruler +set showcmd +set nohlsearch +set incsearch +set ignorecase +set smartindent +set smartcase +set tabstop=4 +set softtabstop=4 +set shiftwidth=4 +set splitbelow set noswapfile -set splitright " split new to the right when doing vertical -set shiftwidth=4 "used for autoindent and << and >> operators in normal mode -set autoindent "copies indent from current line to the next line -set expandtab "tabs will expand to whitespace characters -set esckeys "allows function keys to be recognized in Insert mode -set ttimeoutlen=20 "timeout for a key code mapping -set timeoutlen=1000 "time(ms) to wait for key mappings +set nobackup +set splitright +set autoindent +set expandtab set hidden -set t_Co=256 -"set t_Co=0 - switches off all colours set path+=** +" set relativenumber +" set number set more +set signcolumn=number set colorcolumn=0 set equalalways set showmode -set nobackup -set listchars=tab:»→,trail:␣ -set grepprg=/usr/local/bin/ag - -" i don't bother with folding, but it's here if i need it. +set nolist +set listchars=tab:»-,trail:␣,leadmultispace:---+,eol:\\U000021b5 +set shortmess+=c +set tags+=./tags +set background=light +set completeopt=menuone,longest +" }}} +" Function to allow adding a line of text to taskwarrior {{{ +function! TaskWarriorAddCurrentLine() + let current_line = getline('.') + silent execute ":!task add " . shellescape(current_line) + redraw! + echo "Task added: " . current_line + delete +endfunction +" }}} +" Folding {{{ if has('folding') - set foldmethod=marker - set foldmarker=#\ {{{,#\ }}} + set foldmethod=marker " default + " set foldmethod=syntax +" set foldmarker=#\ {{{,#\ }}} set viewoptions=folds,options,cursor,unix,slash endif - -" from https://www.reddit.com/r/vim/comments/f5gi2g/vim_notetaking_automatic_link_creation_between/ -" copies a link from file from previous buffer for pasting into -" next buffer with "ap -function! s:copy_filename_as_mdlink() - let fname=expand("%") - let @a="[" . fname . "](./" . fname. ")" -endfunction -autocmd BufLeave * call s:copy_filename_as_mdlink() - -" vim-plug -call plug#begin('~/.vim/plugged') +" disable folding by default with vim-markdown +let g:vim_markdown_folding_disabled = 1 +" }}} +" Remaps {{{ +let @x = 'o- [ ] ' +noremap <silent> J 10j +noremap <silent> K 10k +" macro to go to end of sentence and add a line break (for +" one-line-per-sentence vimming...) +let @s = ")i\<BS>\<CR>\<Esc>" +" remap :W to :w - :W was previous Windows in fzf +command! W w +" Open Fern with Ctrl-N +nnoremap <C-n> :Fern -drawer .<CR> <C-w>l +" }}} +" Plugins {{{ +call plug#begin() +"Plug 'vim-scripts/AutoComplPop' +Plug 'lambdalisue/fern.vim', +Plug 'altercation/vim-colors-solarized', +Plug 'tpope/vim-rails', +Plug 'vim-ruby/vim-ruby', +Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } +Plug 'junegunn/fzf.vim' +Plug 'ayu-theme/ayu-vim' +Plug 'airblade/vim-tailwind' +Plug 'vim-perl/vim-perl', { 'for': 'perl', 'do': 'make clean carp dancer highlight-all-pragmas moose test-more try-tiny' } Plug 'morhetz/gruvbox' +Plug 'eemed/sitruuna.vim' +" Plug 'sheerun/vim-polyglot' +Plug 'preservim/vim-markdown' +Plug 'mhinz/vim-signify' +Plug 'vim-test/vim-test' Plug 'ledger/vim-ledger' -"Plug 'prabirshrestha/vim-lsp' -Plug 'ledger/vim-ledger' -Plug 'alok/notational-fzf-vim' -Plug 'sheerun/vim-polyglot' -"Plug 'neoclide/coc.nvim', {'branch': 'release'} -Plug 'tpope/vim-commentary' -Plug 'godlygeek/tabular' -Plug 'davidhalter/jedi' +Plug 'fatih/vim-go', {'do': ':GoUpdateBinaries' } Plug 'tpope/vim-dispatch' -Plug 'tpope/vim-fugitive' -Plug 'tpope/vim-sensible' -Plug 'tpope/vim-unimpaired' Plug 'tpope/vim-surround' -Plug 'dense-analysis/ale' -Plug 'vim-test/vim-test' -Plug 'jlanzarotta/bufexplorer' -Plug 'preservim/nerdtree' -Plug 'mhinz/vim-signify' -Plug 'mattn/emmet-vim' -Plug 'junegunn/fzf' -Plug 'altercation/vim-colors-solarized' -Plug 'junegunn/fzf.vim' -Plug 'SirVer/Ultisnips' +Plug 'tpope/vim-commentary' +Plug 'tpope/vim-unimpaired' +Plug 'tpope/vim-fugitive' +Plug 'SirVer/UltiSnips' Plug 'honza/vim-snippets' -Plug 'pangloss/vim-javascript' -Plug 'fatih/vim-go', { 'tag': '*' } -Plug 'powerman/vim-plugin-AnsiEsc' -"Plug 'majutsushi/tagbar' +Plug 'dense-analysis/ale' call plug#end() - -" vim-test - -" use vim-dispatch to run tests in the quickfix window -" from Modern Vim Ch.4 -" the mappings below are from vim-test -" https://github.com/vim-test/vim-test -" dispatch opens send test output to quickfix window -" let test#strategy = "vimterminal" -let test#strategy = "basic" -let test#python#runner = "pytest" -let test#vim#term_position = "topleft 10" -" let test#python#pytest#options = '-vvv --tb=short' -let test#python#pytest#options = '--tb=short' -let test#go#runner = 'gotest' -"let test#go#gotest#options = '-v' -" To run mypy using vim-dispath -with Dispatch -autocmd FileType python let b:dispatch = 'mypy --ignore-missing-imports' - -" notational-fzf-vim -let g:nv_search_paths = ['~/Notes', '~/Notes/Archive'] - -" jedo-vim -let g:jedi#goto_command = "<leader>d" -let g:jedi#goto_assignments_command = "<leader>g" -let g:jedi#goto_stubs_command = "<leader>s" -let g:jedi#goto_definitions_command = "" -let g:jedi#documentation_command = "K" -let g:jedi#usages_command = "<leader>n" -let g:jedi#completions_command = "<C-Space>" -let g:jedi#rename_command = "<leader>r" - -" test -nmap <silent> t<C-n> :TestNearest<CR> -nmap <silent> t<C-f> :TestFile<CR> -nmap <silent> t<C-s> :TestSuite<CR> -"nmap <silent> t<C-l> :TestLast<CR> -nmap <silent> <S-F10> :TestLast<CR> -nmap <silent> t<C-g> :TestVisit<CR> - -" CoC extensions -"let g:coc_global_extensions = ['coc-tsserver', 'coc-pyright', 'coc-html'] +" }}} +" vim-tailwind {{{ +function! s:is_tailwind() + return !empty(findfile('tailwind.config.js', '.;')) || + \ !empty(findfile('theme/static_src/tailwind.config.js', '.;')) +endfunction -" Coc Use `[g` and `]g` to navigate diagnostics -" Coc Use `:CocDiagnostics` to get all diagnostics of current buffer in location list. -" nmap <silent> [g <Plug>(coc-diagnostic-prev) -" nmap <silent> ]g <Plug>(coc-diagnostic-next) +nmap <silent> <buffer> gk <Plug>(tailwind-lookup) -" " CoC GoTo code navigation. -" nmap <silent> gd <Plug>(coc-definition) -" nmap <silent> gy <Plug>(coc-type-definition) -" nmap <silent> gi <Plug>(coc-implementation) -" -" ALE ale config +autocmd BufEnter *.html,*.slim if s:is_tailwind() | + \ setlocal omnifunc=tailwind#Complete | + \ endif +" }}} +" ALE {{{ +let g:ale_enabled = 1 +let g:ale_set_balloons = 0 let g:ale_echo_msg_format = '[%linter%] %s [%severity%]' -let g:ale_sign_error = '✘' -let g:ale_sign_warning = '⚠' -let g:ale_lint_on_text_changed = 'never' - - +let g:ale_sign_error = '!' +let g:ale_sign_warning = '?' +let g:ale_lint_on_text_changed = 1 let g:ale_hover_cursor = 1 -let g:ale_enabled = 1 +let g:ale_virtualtext_cursor = 'disabled' let g:ale_sign_column_always = 1 let g:ale_open_list = 0 let g:ale_set_highlights = 1 let g:ale_set_signs = 1 let g:ale_set_loclist = 1 -let g:ale_set_quickfix = 0 +let g:ale_set_quickfix = 1 let g:ale_echo_cursor = 1 -let g:ale_echo_msg_error_str = 'Error' -let g:ale_echo_msg_format = '%linter% - %code: %%s' -let g:ale_loclist_msg_format = '%linter% - %code: %%s' -let g:ale_echo_msg_warning_str = 'Warning' -let g:ale_linters = {'python': ['flake8', 'mypy'], +let g:ale_echo_msg_error_str = 'ALE Error' +let g:ale_echo_msg_format = 'ALE: %linter% - %code: %%s' +let g:ale_loclist_msg_format = 'ALE: %linter% - %code: %%s' +let g:ale_echo_msg_warning_str = 'ALE Warning' +let g:ale_linters = {'python': ['pyright', 'flake8', 'mypy'], \ 'ocaml': ['merlin'], -\ 'cpp': ['clang'], +\ 'javascript': ['eslint'], +\ 'cpp': ['clangd'], \ 'yaml': ['yamllint'], -\ 'c': ['clang'], +\ 'c': ['clangd'], \ 'go': ['gopls', 'golint', 'gofmt'], \} let g:ale_fixers = { -\ 'python': ['isort', 'yapf', 'black'], -\ 'go': ['gofmt'], +\ 'python': ['autoimport', 'isort', 'yapf', 'black'], +\ 'javascript': ['eslint'], +\ 'go': ['gofmt', 'goimports', 'gopls'], +\ 'cpp': ['clang-format'], +\ 'c': ['clang-format'], \ 'rust': ['rustfmt'] \ } let g:ale_python_mypy_ignore_invalid_syntax = 1 @@ -264,99 +222,54 @@ let g:ale_python_mypy_options = '--config-file mypy.ini' " let g:ale_sign_error = '>>' let g:ale_fix_on_save = 1 let g:ale_linters_explicit = 0 -nmap <silent> gr <Plug>(coc-references) - -" Use K to show documentation in preview window. -"nnoremap <silent> K :call <SID>show_documentation()<CR> - -" function! s:show_documentation() -" if (index(['vim','help'], &filetype) >= 0) -" execute 'h '.expand('<cword>') -" elseif (coc#rpc#ready()) -" call CocActionAsync('doHover') -" else -" execute '!' . &keywordprg . " " . expand('<cword>') -" endif -" endfunction -" -"" Quick Editing vimrc -nnoremap <leader>ev <C-w>s<C-w>j<C-w>L:e $MYVIMRC<cr> - -" Highlight the symbol and its references when holding the cursor. -" autocmd CursorHold * silent call CocActionAsync('highlight') - -" clear search highlights -nnoremap <leader><space> :noh<cr>:call clearmatches()<cr> - -" previews in netrw -let g:netrw_preview = 1 - -" journal stuff -autocmd BufNewFile,BufReadPost *.md map <leader>jj <Esc>:r! date +" - \%H:\%M: "<ENTER>kJA<Esc>$<space><Esc> -autocmd BufNewFile,BufReadPost *.md map <leader>jd <Esc>:r! date +"(\%Y-\%m-\%dT\%H:\%M)"<ENTER>i<backspace><space><Esc> - -" switch off Coc with Markdown -autocmd FileType markdown let b:coc_suggest_disable = 1 - -syntax on "turn syntax highlighting on -filetype plugin indent on "load plugin and indent files associated a detected filetype -runtime macros/matchit.vim "allows jumping between brackets with % in normal mode - -" Go stuff -let g:go_highlight_fields = 1 -let g:go_highlight_functions = 1 -let g:go_highlight_function_calls = 1 -let g:go_highlight_extra_types = 1 -let g:go_highlight_operators = 1 -let g:go_doc_keywordprg_enabled = 1 -let g:go_list_height = 0 -let g:go_highlight_operators = 1 -let g:go_highlight_function_parameters = 1 -let g:go_doc_max_height = 50 -let g:go_doc_popup_window = 1 -let g:go_list_height = 10 - - -" vim-go debugger window settings -let g:go_debug_windows = { - \ 'vars': 'leftabove 40vnew', - \ 'stack': 'leftabove 20new', - \ 'goroutines': 'botright 10new', - \ 'out': 'botright 5new', -\ } - -" vim-go and gopls -let g:go_def_mode='gopls' -let g:go_info_mode='gopls' -let g:go_play_browser_command = 'firefox %URL% &' -let g:go_test_show_name = 1 -let g:go_auto_type_info = 1 -let test#go#runner = 'gotest' -let g:go_term_mode = "split" -let g:go_term_height = 50 -let g:go_highlight_fields = 1 -let g:go_highlight_functions = 1 +let g:ale_completion_enabled = 0 +set omnifunc=ale#completion#OmniFunc +" }}} +" :grep use ripgrep {{{ +if executable('rg') + set grepprg=rg\ --color=never\ --vimgrep +endif -"autocmd FileType go nmap <leader>r :w<CR>:split <bar> terminal go run %<CR> -autocmd FileType go nmap <leader>R :GoRun<CR> -" highlights the variable in the file for you.. -"let g:go_auto_sameids = 1 -" auto import... -let g:go_fmt_command = "goimports" -" automatic type info on cursor -let g:go_auto_type_info = 1 -let g:go_snippet_engine = "ultisnips" -au Filetype go nmap <leader>ga <Plug>(go-alternate-edit) -au Filetype go nmap <leader>gah <Plug>(go-alternate-split) -au Filetype go nmap <leader>gav <Plug>(go-alternate-vertical) -au FileType go nmap <F8> :GoTestFunc -short<cr> -au FileType go nmap <F10> :GoTest -short<cr> -au FileType go nmap <F9> :DlvToggleBreakpoint<CR> -au FileType go nmap <S-F9> :DlvTest<CR> -au FileType go nmap <F11> :DlvDebug<CR> -au FileType go nmap <S-F5> :GoRename<CR> +" and search with ripgrep +command! -bang -nargs=* Rg + \ call fzf#vim#grep( + \ 'rg --column --line-number --no-heading --color=always --ignore-case '.shellescape(<q-args>), 1, + \ <bang>0 ? fzf#vim#with_preview('up:60%') + \ : fzf#vim#with_preview('right:50%:hidden', '?'), + \ <bang>0) -" FZF +nnoremap <C-p>a :Rg +" }}} +" 'Notes Grep' with ripgrep (see grepprg) {{{ +" -i case insensitive +" -g glob pattern +" ! to not immediately open first search result +"command! -nargs=1 Ngrep :silent grep! "<args>" -i -g '*.md' $NOTES_DIR | execute ':redraw!' +command! -nargs=1 Ngrep vimgrep "<args>" $NOTES_DIR/**/*.md +nnoremap <leader>nn :Ngrep +" }}} +" vim-test {{{ +nmap <silent> tn :TestNearest<CR> +nmap <silent> tf :TestFile<CR> +nmap <silent> ts :TestSuite<CR> +nmap <silent> tl :TestLast<CR> +nmap <silent> <leader>tv :TestVisit<CR> +let test#strategy = "basic" +let test#python#pytest#options = '-q -s' +let test#python#runner = 'pytest' +let test#vimterminal#term_position = "belowright" +" }}} +" Titbits {{{ +" " Increment an ordered (numbered) list with <leader><cr> +" inoremap <leader><cr> <esc>yyp<C-a> +" " sudo write +" command! S :w !sudo tee % + +"nnoremap <Tab> % +nnoremap <C-@> :call system("wl-copy", @")<CR> +xnoremap <silent> <C-@> :w !wl-copy<CR><CR> +" }}} +" FZF {{{ " This is the default extra key bindings let g:fzf_action = { \ 'ctrl-t': 'tab split', @@ -384,110 +297,107 @@ let g:fzf_colors = " (https://github.com/zenbro/dotfiles/blob/master/.nvimrc#L151-L187) let g:fzf_nvim_statusline = 0 " disable statusline overwriting -" command history is :History: nnoremap <C-s> :GFiles!<CR> - nnoremap <leader><C-p> :<C-u>FZF!<CR> - nnoremap <leader>t :Files<CR> - nnoremap <leader>o :Tags<CR> - nnoremap <leader>h :History<CR> - nnoremap <silent> <leader>0 :Files<CR> - nnoremap <silent> <leader>; :BLines<CR> - nnoremap <silent> <leader>l :Lines<CR> - nnoremap <silent> <leader>o :BTags<CR> - nnoremap <silent> <leader>bu :Buffers<CR> - nnoremap <silent> <leader>? :History:<CR> - nnoremap <silent> <leader>/ :execute 'Ag ' . input('Ag/')<CR> - nnoremap <silent> <leader>P :call SearchWordWithAg()<CR> - vnoremap <silent> <leader>P :call SearchVisualSelectionWithAg()<CR> - nnoremap <silent> <leader>ft :Filetypes<CR> - nnoremap <silent> <leader>CC :Commands<CR> imap <C-x><C-f> <plug>(fzf-complete-file-ag) imap <C-x><C-l> <plug>(fzf-complete-line) - -" Search with ripgrep -command! -bang -nargs=* Rg - \ call fzf#vim#grep( - \ 'rg --column --line-number --no-heading --color=always --ignore-case '.shellescape(<q-args>), 1, - \ <bang>0 ? fzf#vim#with_preview('up:60%') - \ : fzf#vim#with_preview('right:50%:hidden', '?'), - \ <bang>0) - -nnoremap <C-p>a :Rg - -"" Quick Editing vimrc -nnoremap <leader>ev <C-w>s<C-w>j<C-w>L:e $MYVIMRC<cr> - -" dracula (must be set before colorscheme) -"let g:dracula_colorterm = 0 -"let g:dracula_bold = 1 -"let g:dracula_italic = 0 " this has to be set to 0 to avoid lots of erroneous highlighting (https://github.com/dracula/vim/issues/219) -"let g:dracula_underline = 1 - - -" Colorscheme - -" this stuff from https://github.com/morhetz/gruvbox/wiki/Terminal-specific -"Use e 24-bit (true-color) mode in Vim/Neovim when outside tmux. +" }}} +" Colorscheme {{{ +" This is imported from the old ephemera.vim file which has now been removed +" +" I got the following from gruvbox docs +"Use 24-bit (true-color) mode in Vim/Neovim when outside tmux. "If you're using tmux version 2.2 or later, you can remove the outermost $TMUX check and use tmux's 24-bit color support "(see < http://sunaku.github.io/tmux-24bit-color.html#usage > for more information.) -if (empty($TMUX)) - if (has("nvim")) - "For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 > - let $NVIM_TUI_ENABLE_TRUE_COLOR=1 - endif - "For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 > - "Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd > - " < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 > - if (has("termguicolors")) - set termguicolors - endif +if (has("nvim")) +"For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 > + let $NVIM_TUI_ENABLE_TRUE_COLOR=1 +endif +"For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 > +"Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd > +" < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 > +if (has("termguicolors")) + set termguicolors endif -syntax enable -let g:solarized_termcolors=256 - -let g:gruvbox_termcolors=256 -let g:gruvbox_contrast_dark='hard' -let g:gruvbox_contrast_light='hard' -let g:gruvbox_hls_cursor='orange' -let g:gruvbox_sign_column='bg0' -let g:gruvbox_number_column='bg0' -let g:gruvbox_invert_signs='0' -let g:gruvbox_improved_strings='0' -set background=dark -colorscheme industry -"colorscheme delek -" -" manual highlights -" highlight Visual ctermfg=black ctermbg=LightMagenta -" highlight SignColumn ctermbg=black ctermfg=white -" highlight Comment ctermfg=DarkGray -" highlight DiffAdd term=bold ctermfg=yellow ctermbg=black -" highlight DiffDelete term=bold ctermfg=red ctermbg=black -" highlight DiffChange term=bold ctermfg=black ctermbg=DarkGreen - - -map <F7> :if exists("g:syntax_on") <Bar> -\ syntax off <Bar> -\ else <Bar> -\ syntax enable <Bar> -\ endif <CR> - -augroup general - autocmd! - "keep equal proportions when windows resized - autocmd VimResized * wincmd = - "save cursor position in a file - autocmd BufReadPost * if line("'\"") > 1 && line("'\"") - \ <= line("$") | exe "normal! g'\"" | endif +"ayu theme +" let ayucolor="light" " for light version of theme +" let ayucolor="mirage" " for mirage version of theme +let ayucolor="dark" " for dark version of theme + +"colorscheme gruber-darker +let g:gruvbox_contrast_dark = "hard" +let g:gruvbox_italicize_strings = 1 +let g:gruvbox_improved_strings = 1 +let g:gruvbox_improved_warnings = 1 +let g:gruvbox_invert_indent_guides = 1 +let g:gruvbox_invert_signs = 1 +"colorscheme evening +"colorscheme sitruuna +"colorscheme ayu +colorscheme solarized +"colorscheme gruvbox +" }}} +" GPG files {{{ +" from https://vim.fandom.com/wiki/Edit_gpg_encrypted_files +" Don't save backups of *.gpg files +set backupskip+=*.gpg +" To avoid that parts of the file is saved to .viminfo when yanking or +" deleting, empty the 'viminfo' option. +set viminfo= + +augroup encrypted + au! + " Disable swap files, and set binary file format before reading the file + autocmd BufReadPre,FileReadPre *.gpg + \ setlocal noswapfile bin + " Decrypt the contents after reading the file, reset binary file format + " and run any BufReadPost autocmds matching the file name without the .gpg + " extension + autocmd BufReadPost,FileReadPost *.gpg + \ execute "'[,']!gpg --decrypt --default-recipient-self" | + \ setlocal nobin | + \ execute "doautocmd BufReadPost " . expand("%:r") + " Set binary file format and encrypt the contents before writing the file + autocmd BufWritePre,FileWritePre *.gpg + \ setlocal bin | + \ '[,']!gpg --encrypt --default-recipient-self + " After writing the file, do an :undo to revert the encryption in the + " buffer, and reset binary file format + autocmd BufWritePost,FileWritePost *.gpg + \ silent u | + \ setlocal nobin augroup END - -augroup languages +" }}} +" Golang {{{ +augroup golang autocmd! - autocmd BufNewFile,BufRead *.bash set syntax=sh - autocmd FileType python xnoremap <leader>r <esc>:'<,'>:w !python3<CR> - autocmd FileType go set noexpandtab - autocmd FileType html :syntax sync fromstart - autocmd FileType html,javascript,css,json,yaml,sh - \ setlocal ts=2 sts=2 sw=2 expandtab -augroup ENDj + autocmd FileType go + \ set tabstop=8 | + \ set softtabstop=8 | + \ set shiftwidth=8 +augroup END +" }}} +" GitFZF {{{ +" from https://git.sr.ht/~sircmpwn/dotfiles/tree/master/item/.vimrc +function! GitFZF() + let path = trim(system('cd '.shellescape(expand('%:p:h')).' && git rev-parse --show-toplevel')) + exe 'FZF ' . path +endfunction +command! GitFZF call GitFZF() +nnoremap <leader><C-f> :GitFZF<CR> +" }}} +" Switching off colours {{{ +"syntax off +" hi Visual term=reverse ctermbg=7 ctermfg=black guifg=black guibg=LightPink +" hi SpellBad term=reverse ctermbg=224 gui=undercurl guisp=Red guibg=Red +" hi SpellCap term=reverse ctermbg=224 gui=undercurl guisp=Red guibg=Red +" hi SpellRare term=reverse ctermbg=224 gui=undercurl guisp=Red guibg=Blue +" hi Search term=reverse ctermbg=11 guifg=black guibg=Green +"}}} +" Turn spelling on for text files {{{ +" from - https://dmerej.info/blog/post/syntax-highlighting-is-useless/ +augroup textfiles + autocmd! + autocmd filetype markdown setlocal spell spelllang=en +augroup end +" }}} |