From 92cca5fbd9307bfaea3bd3a087648f26e50eeb57 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Wed, 30 Aug 2023 20:06:05 +0100 Subject: Reverts a lot of stuff for vim --- vim/vimrc | 282 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 257 insertions(+), 25 deletions(-) (limited to 'vim') diff --git a/vim/vimrc b/vim/vimrc index 14cec53..ae93021 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -45,50 +45,182 @@ set signcolumn=number set colorcolumn=0 set equalalways set showmode -set list -" set listchars=tab:»-,trail:␣,leadmultispace:---+,eol:\\U000021b5 -set listchars=tab:»-,trail:␣ +set nolist +set listchars=tab:»-,trail:␣,leadmultispace:---+,eol:\\U000021b5 set shortmess+=c set tags+=./tags +set background=dark set completeopt=menuone,longest -set omnifunc=syntaxcomplete#Complete + + +" 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 + +nnoremap q :call TaskWarriorAddCurrentLine() + + +" macro to go to end of sentence and add a line break (for +" one-line-per-sentence vimming...) +let @s = ")i\\\" + +" i don't bother with folding, but it's here if i need it. +if has('folding') + set foldmethod=marker + set foldmarker=#\ {{{,#\ }}} + set viewoptions=folds,options,cursor,unix,slash +endif + +" disable folding by default with vim-markdown +let g:vim_markdown_folding_disabled = 1 + +" Open vimrc +nnoremap ev sjL:e $HOME/.vim/vimrc + +" Jump up or down by 10 lines. +noremap J 10j +noremap K 10k + +" Place timestamps, be it date (YYYY-MM-DD) or time (HH:MM:SS). +if (exists("*strftime")) + noremap date "=strftime("%F")p9h + noremap time "=strftime("%X")p7h +endif + +" Place timestamps, be it date (YYYY-MM-DD) or time (HH:MM:SS). +if (exists("*strftime")) + noremap date "=strftime("%F")p9h + noremap time "=strftime("%X")p7h +endif + +"keymap for Fern +nnoremap ;f :Fern . -drawer call plug#begin() -Plug 'dense-analysis/ale' +"Plug 'vim-scripts/AutoComplPop' +Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } +Plug 'junegunn/fzf.vim' +Plug 'catppuccin/nvim', { 'as': 'catppuccin' } +Plug 'ayu-theme/ayu-vim' +Plug 'szw/vim-maximizer' +Plug 'ycm-core/YouCompleteMe' +Plug 'airblade/vim-tailwind' +Plug 'morhetz/gruvbox' +Plug 'lambdalisue/fern.vim' +Plug 'junegunn/goyo.vim' +" Plug 'sheerun/vim-polyglot' +Plug 'preservim/vim-markdown' Plug 'mhinz/vim-signify' +Plug 'vim-test/vim-test' +Plug 'ledger/vim-ledger' +Plug 'fatih/vim-go', {'do': ':GoUpdateBinaries' } Plug 'tpope/vim-dispatch' -Plug 'tpope/vim-fugitive' +Plug 'tpope/vim-surround' Plug 'tpope/vim-commentary' +Plug 'tpope/vim-unimpaired' +Plug 'tpope/vim-fugitive' Plug 'SirVer/UltiSnips' Plug 'honza/vim-snippets' -Plug 'ledger/vim-ledger' -" Plug 'sheerun/vim-polyglot' - +Plug 'dense-analysis/ale' +Plug 'tomasiser/vim-code-dark' call plug#end() +" maximize current split or return to previous +noremap m :MaximizerToggle + +" vim-tailwind +function! s:is_tailwind() + return !empty(findfile('tailwind.config.js', '.;')) || + \ !empty(findfile('theme/static_src/tailwind.config.js', '.;')) +endfunction + +nmap gk (tailwind-lookup) + +autocmd BufEnter *.html,*.slim if s:is_tailwind() | + \ setlocal omnifunc=tailwind#Complete | + \ endif + +" YCM +" *** STARTING AND ENABLING *** +" Don't start on start - or use show_diagnostics below +"let g:loaded_youcompleteme = 1 +" +" with this set to 0, YCM doesn't load/start +let g:ycm_show_diagnostics_ui = 1 +" ****************************** + +let g:ycm_enable_inlay_hints = 1 +nnoremap h (YCMToggleInlayHints) +nnoremap gd :YcmCompleter GoToDefinition +nnoremap gr :YcmCompleter GoToReferences +nnoremap K :YcmCompleter GetDoc +" this will disable tab, allowing it to be used for ultisnips +" let g:ycm_key_list_select_completion=[] +" let g:ycm_key_list_previous_completion=[] +let g:ycm_key_list_select_completion = ['', ''] +let g:ycm_key_list_previous_completion = ['', ''] +let g:ycm_python_interpreter_path = '.venv/bin/python3' +let g:ycm_auto_trigger = 1 +let g:ycm_python_sys_path = [] +let g:ycm_extra_conf_vim_data = [ + \ 'g:ycm_python_interpreter_path', + \ 'g:ycm_python_sys_path' + \] +"let g:ycm_global_ycm_extra_conf = '~/.global_extra_conf.py' +nnoremap jd :YcmCompleter GoTo +imap (YCMToggleSignatureHelp)'. + + +let g:ycm_enable_inlay_hints = 0 + +" ALE ale config +let g:ale_enabled = 1 +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 = 0 +let g:ale_hover_cursor = 0 +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 = 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': ['pyright', 'flake8', 'mypy'], -\ 'javascript': ['eslint'], +\ 'ocaml': ['merlin'], +\ 'javascript': ['eslint'], \ 'cpp': ['clangd'], \ 'yaml': ['yamllint'], \ 'c': ['clangd'], \ 'go': ['gopls', 'golint', 'gofmt'], -\} + \} let g:ale_fixers = { -\ 'python': ['autoimport', 'isort', 'yapf', 'black'], -\ 'javascript': ['eslint'], -\ 'go': ['gofmt'], -\ 'cpp': ['clang-format'], -\ 'c': ['clang-format'], -\ 'rust': ['rustfmt'] -\} +\ 'python': ['autoimport', 'isort', 'yapf', 'black'], +\ 'javascript': ['eslint'], +\ 'go': ['gofmt'], +\ 'cpp': ['clang-format'], +\ 'c': ['clang-format'], +\ 'rust': ['rustfmt'] +\ } +let g:ale_python_mypy_ignore_invalid_syntax = 1 +let g:ale_python_mypy_executable = 'mypy' +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_sign_column_always = 1 +let g:ale_linters_explicit = 0 set omnifunc=ale#completion#OmniFunc - -" Open vimrc -nnoremap ev sjL:e $HOME/.vim/vimrc - " Make :grep use ripgrep if executable('rg') set grepprg=rg\ --color=never\ --vimgrep @@ -104,6 +236,36 @@ command! -bang -nargs=* Rg nnoremap a :Rg +" Generate ctags for current working directory +nnoremap tt :silent !ctags -R . :redraw! + +" notes stuff - from https://www.edwinwenink.xyz/posts/43-notes_tagging/ +" Go to index of notes and set working directory to my notes +nnoremap ni :e $NOTES_DIR/index.md:cd $NOTES_DIR + +" '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! "" -i -g '*.md' $NOTES_DIR | execute ':redraw!' +command! -nargs=1 Ngrep vimgrep "" $NOTES_DIR/**/*.md +nnoremap nn :Ngrep + +" Open quickfix list in a right vertical split (good for Ngrep results) +command! Vlist botright vertical copen | vertical resize 50 +nnoremap v : Vlist + +" vim-test +nmap tn :TestNearest +nmap tf :TestFile +nmap ts :TestSuite +nmap tl :TestLast +nmap tv :TestVisit +let test#strategy = "basic" +let test#python#pytest#options = '-q -s' +let test#python#runner = 'pytest' +let test#vimterminal#term_position = "belowright" + " clear search highlights nnoremap :noh:call clearmatches() @@ -112,10 +274,80 @@ runtime macros/matchit.vim "allows jumping between brackets with % in normal mod " remap :W to :w - :W was previous Windows in fzf command! W w +" FZF +" This is the default extra key bindings +let g:fzf_action = { + \ 'ctrl-t': 'tab split', + \ 'ctrl-x': 'split', + \ 'ctrl-v': 'vsplit' } + +" - FZF Popup window (center of the screen) +let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } } + +" Customize fzf colors to match your color scheme +let g:fzf_colors = +\ { 'fg': ['fg', '#f8f8f2'], + \ 'bg': ['bg', '#282a36'], + \ 'hl': ['fg', '#bd93f9'], + \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], + \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], + \ 'hl+': ['fg', 'Statement'], + \ 'info': ['fg', '#ffb86c'], + \ 'prompt': ['fg', '#50fa7b'], + \ 'pointer': ['fg', 'Exception'], + \ 'marker': ['fg', 'Keyword'], + \ 'spinner': ['fg', '#ffb86c'], + \ 'header': ['fg', '#6272a4'] } +" More fzf settings +" (https://github.com/zenbro/dotfiles/blob/master/.nvimrc#L151-L187) + let g:fzf_nvim_statusline = 0 " disable statusline overwriting + + nnoremap :GFiles! + nnoremap :FZF! + nnoremap t :Files + nnoremap o :Tags + nnoremap h :History + nnoremap 0 :Files + nnoremap ; :BLines + nnoremap l :Lines + nnoremap o :BTags + nnoremap b :Buffers + nnoremap ? :History: + nnoremap / :execute 'Ag ' . input('Ag/') + nnoremap ft :Filetypes + nnoremap CC :Commands + imap (fzf-complete-file-ag) + imap (fzf-complete-line) + +" COLORSCHEME BITS - +" 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 (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 -set background=dark -colorscheme gruber-darker +"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 = 0 +colorscheme ayu +" END OF COLORSCHEME BITS - -- cgit v1.2.3