From 34cea963ffa733345f5c0fb3718a89eb59dd37f9 Mon Sep 17 00:00:00 2001 From: "jakob.stendahl" Date: Tue, 27 Feb 2024 22:17:45 +0100 Subject: Cleanup --- Common/nvim/lua/basic.lua | 4 +- Common/nvim/lua/plugins.lua | 2 +- Common/vimrc | 411 +------------------------------------------- 3 files changed, 6 insertions(+), 411 deletions(-) (limited to 'Common') diff --git a/Common/nvim/lua/basic.lua b/Common/nvim/lua/basic.lua index 82c0194..9e40930 100755 --- a/Common/nvim/lua/basic.lua +++ b/Common/nvim/lua/basic.lua @@ -43,7 +43,7 @@ VIM User interface --]] -- Set 3 lines to the cursor - when moving vertically using j/k -vim.opt.so = 3 +-- vim.opt.so = 3 -- set WildMenu --vim.opt.wildmenu = true @@ -56,7 +56,7 @@ vim.opt.wildignore:append('*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store') --vim.opt.ruler = true -- Hide buffers when they are abandoned -vim.opt.hid = true +-- vim.opt.hid = true -- Make backspace function normally vim.opt.backspace = 'eol,start,indent' diff --git a/Common/nvim/lua/plugins.lua b/Common/nvim/lua/plugins.lua index b08c2af..2866731 100755 --- a/Common/nvim/lua/plugins.lua +++ b/Common/nvim/lua/plugins.lua @@ -17,7 +17,7 @@ return require('packer').startup(function(use) -- Packer itself :) use 'wbthomason/packer.nvim' - -- GitSigns + -- Git plugins use { 'lewis6991/gitsigns.nvim', config = function() diff --git a/Common/vimrc b/Common/vimrc index 098db18..fa27062 100644 --- a/Common/vimrc +++ b/Common/vimrc @@ -1,30 +1,3 @@ - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Maintainer: -" jakobs1n -" -" Version: -" 1.0 - 29/11/19 -" -" Sections: -" -> General -" -> VIM user interface -" -> Colors and Fonts -" -> Files and backups -" -> Text, tab and indent related -" -> Visual mode related -" -> Moving around, tabs and buffers -" -> Status line -" -> Editing mappings -" -> vimgrep searching and cope displaying -" -> Spell checking -" -> Misc -" -> Helper functions -" -> Plugins -" -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - - """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => General """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -43,9 +16,6 @@ set autoread let mapleader = "," let g:mapleader = "," -" Fast saving -nmap w :w! - " :W sudo saves the file " (useful for handling the permission-denied error) command W w !sudo tee % > /dev/null @@ -54,32 +24,17 @@ command W w !sudo tee % > /dev/null """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => VIM user interface """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Set 7 lines to the cursor - when moving vertically using j/k -set so=7 - -" Avoid garbled characters in Chinese language windows OS -let $LANG='en' -set langmenu=en -source $VIMRUNTIME/delmenu.vim -source $VIMRUNTIME/menu.vim +set so=3 " Turn on the WiLd menu set wildmenu " Ignore compiled files -set wildignore=*.o,*~,*.pyc -if has("win16") || has("win32") - set wildignore+=.git\*,.hg\*,.svn\* -else - set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store -endif +set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store "Always show current position set ruler -" Height of the command bar -"set cmdheight=2 - " A buffer becomes hidden when it is abandoned set hid @@ -116,15 +71,6 @@ set novisualbell set t_vb= set tm=500 -" Properly disable sound on errors on MacVim -if has("gui_macvim") - autocmd GUIEnter * set vb t_vb= -endif - - -" Add a bit extra margin to the left -set foldcolumn=1 - " Show leader commands set showcmd @@ -137,26 +83,7 @@ set colorcolumn=80 " Enable syntax highlighting syntax enable -" Enable 256 colors palette in Gnome Terminal -if $COLORTERM == 'gnome-terminal' - set t_Co=256 -endif - -try - colorscheme ron - -catch -endtry -"so ~/.vim/ThemerVim.vim -"set background=dark - -" Set extra options when running in GUI mode -if has("gui_running") - set guioptions-=T - set guioptions-=e - set t_Co=256 - set guitablabel=%M\ %t -endif +set background=light " Set utf8 as standard encoding and en_US as the standard language set encoding=utf8 @@ -183,43 +110,18 @@ set noswapfile " Use spaces instead of tabs set expandtab -" Be smart when using tabs ;) -" set smarttab - " 1 tab == 4 spaces set shiftwidth=4 set tabstop=4 set softtabstop=4 -" Linebreak on 500 characters -set lbr -set tw=500 - set ai "Auto indent set si "Smart indent set wrap "Wrap lines -" Set options for spesific filetypes -autocmd FileType vhd setlocal shiftwidth=2 -autocmd FileType vhd setlocal shiftwidth=2 - - -"""""""""""""""""""""""""""""" -" => Visual mode related -"""""""""""""""""""""""""""""" -" Visual mode pressing * or # searches for the current selection -" Super useful! From an idea by Michael Naumann -vnoremap * :call VisualSelection('', '')/=@/ -vnoremap # :call VisualSelection('', '')?=@/ - - """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Moving around, tabs, windows and buffers """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Map to / (search) and Ctrl- to ? (backwards search) -map / -map ? - " Disable highlight when is pressed map :noh @@ -229,42 +131,6 @@ map k map h map l -" Close the current buffer -map bd :Bclose:tabclosegT - -" Close all the buffers -map ba :bufdo bd - -map l :bnext -map h :bprevious - -" Useful mappings for managing tabs -map tn :tabnew -map to :tabonly -map tc :tabclose -map tm :tabmove -map t :tabnext - -" Let 'tl' toggle between this and the last accessed tab -let g:lasttab = 1 -nmap tl :exe "tabn ".g:lasttab -au TabLeave * let g:lasttab = tabpagenr() - - -" Opens a new tab with the current buffer's path -" Super useful when editing files in the same directory -map te :tabedit =expand("%:p:h")/ - -" Switch CWD to the directory of the open buffer -map cd :cd %:p:h:pwd - -" Specify the behavior when switching between buffers -try - set switchbuf=useopen,usetab,newtab - set stal=2 -catch -endtry - " Return to last edit position when opening files (You want this!) au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif @@ -286,69 +152,12 @@ endif " Always show the status line set laststatus=2 -" Format the status line -" TODO: Check this thing! -" set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Editing mappings -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Remap VIM 0 to first non-blank character -map 0 ^ - -" Move a line of text using ALT+[jk] or Command+[jk] on mac -nmap mz:m+`z -nmap mz:m-2`z -vmap :m'>+`mzgv`yo`z -vmap :m'<-2`>my` - nmap - vmap - vmap -endif - -" Delete trailing white space on save, useful for some filetypes ;) -fun! CleanExtraSpaces() - let save_cursor = getpos(".") - let old_query = getreg('/') - silent! %s/\s\+$//e - call setpos('.', save_cursor) - call setreg('/', old_query) -endfun - -if has("autocmd") - autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces() -endif - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Spell checking -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Pressing ,ss will toggle and untoggle spell checking -map ss :setlocal spell! - -" Shortcuts using -map sn ]s -map sp [s -map sa zg -map s? z= - - """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Misc """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Remove the Windows ^M - when the encodings gets messed up -noremap m mmHmt:%s///ge'tzt'm - " Quickly open a buffer for scribble map q :e ~/buffer -" Quickly open a markdown buffer for scribble -map x :e ~/buffer.md - " Toggle paste mode on and off map pp :setlocal paste! @@ -360,10 +169,6 @@ set title " Toggle displaying special characters map :call ToggleListChars() -" Load and save session -map sm :mksession! vim_session.vim -map sl :source vim_session.vim - """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Helper functions """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -388,213 +193,3 @@ function! HasPaste() endif return '' endfunction - -" Don't close window, when deleting a buffer -command! Bclose call BufcloseCloseIt() -function! BufcloseCloseIt() - let l:currentBufNum = bufnr("%") - let l:alternateBufNum = bufnr("#") - - if buflisted(l:alternateBufNum) - buffer # - else - bnext - endif - - if bufnr("%") == l:currentBufNum - new - endif - - if buflisted(l:currentBufNum) - execute("bdelete! ".l:currentBufNum) - endif -endfunction - -function! CmdLine(str) - exe "menu Foo.Bar :" . a:str - emenu Foo.Bar - unmenu Foo -endfunction - -function! VisualSelection(direction, extra_filter) range - let l:saved_reg = @" - execute "normal! vgvy" - - let l:pattern = escape(@", "\\/.*'$^~[]") - let l:pattern = substitute(l:pattern, "\n$", "", "") - - if a:direction == 'gv' - call CmdLine("Ack '" . l:pattern . "' " ) - elseif a:direction == 'replace' - call CmdLine("%s" . '/'. l:pattern . '/') - endif - - let @/ = l:pattern - let @" = l:saved_reg -endfunction - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Plugins -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - -call plug#begin() -Plug 'scrooloose/nerdTree' -Plug 'ctrlpvim/ctrlp.vim' -Plug 'bling/vim-airline' -Plug 'vim-airline/vim-airline-themes' -Plug 'tpope/vim-fugitive' -Plug 'ARM9/arm-syntax-vim' -Plug 'airblade/vim-gitgutter' -Plug 'junegunn/fzf' -Plug 'junegunn/fzf.vim' -Plug 'terryma/vim-multiple-cursors' -Plug 'preservim/nerdcommenter' -Plug 'neoclide/coc.nvim', {'branch': 'release'} -Plug 'evanleck/vim-svelte', {'branch': 'main'} -Plug 'preservim/tagbar' -Plug 'evanleck/vim-svelte', {'branch': 'main'} -Plug 'tpope/vim-dadbod' -Plug 'christoomey/vim-tmux-navigator' -Plug 'tpope/vim-dotenv' -Plug 'kristijanhusak/vim-dadbod-ui' -Plug 'zivyangll/git-blame.vim' -Plug 'smithbm2316/centerpad.nvim' - -"Plug 'neoclide/coc-tsserver', {'do': 'yarn install --frozen-lockfile'} -"Plug 'clangd/coc-clangd', {'do': 'yarn install --frozen-lockfile'} -"Plug 'voldikss/coc-cmake', {'do': 'yarn install --frozen-lockfile'} -"Plug 'neoclide/coc-css', {'do': 'yarn install --frozen-lockfile'} -"Plug 'neoclide/coc-eslint', {'do': 'yarn install --frozen-lockfile'} -"Plug 'neoclide/coc-highlight', {'do': 'yarn install --frozen-lockfile'} -"Plug 'neoclide/coc-html', {'do': 'yarn install --frozen-lockfile'} -"Plug 'neoclide/coc-java', {'do': 'yarn install --frozen-lockfile'} -"Plug 'fannheyward/coc-pyright', {'do': 'yarn install --frozen-lockfile'} -"Plug 'josa42/coc-sh', {'do': 'yarn install --frozen-lockfile'} -"Plug 'fannheyward/coc-texlab', {'do': 'yarn install --frozen-lockfile'} -"Plug 'dense-analysis/ale' -call plug#end() - -" Setup AirLine -let g:airline_powerline_fonts = 1 -if !exists('g:airline_symbols') - let g:airline_symbols = {} -endif -"let g:airline_symbols.space = "\ua0" - -let g:airline#extensions#tabline#enabled = 1 -let g:airline#extensions#tabline#show_buffers = 0 -let g:airline_theme='minimalist' - -let g:airline#extensions#hunks#enabled=0 -let g:airline#extensions#branch#enabled=1 - -" Setup NerdTree -let NERDTreeShowHidden=1 -map :NERDTreeToggle - -" Setup tagbar -map :TagbarToggle - -" Map FuzzyFinder key to ; -map ; :Files -" Add fzf path for mac -set rtp+=/usr/local/opt/fzf - -" Setup Coc -" Always show the signcolumn, otherwise it would shift the text each time -" diagnostics appear/become resolved. -if has("patch-8.1.1564") - " Recently vim can merge signcolumn and number column into one - set signcolumn=number -else - set signcolumn=yes -endif -" Use tab for trigger completion with characters ahead and navigate. -" NOTE: Use command ':verbose imap ' to make sure tab is not mapped by -" other plugin before putting this into your config. -inoremap - \ pumvisible() ? "\" : - \ check_back_space() ? "\" : - \ coc#refresh() -inoremap pumvisible() ? "\" : "\" - -function! s:check_back_space() abort - let col = col('.') - 1 - return !col || getline('.')[col - 1] =~# '\s' -endfunction - -" GoTo code navigation. -nmap gd (coc-definition) -nmap gy (coc-type-definition) -nmap gi (coc-implementation) -nmap gr (coc-references) - -" Use K to show documentation in preview window. -nnoremap K :call show_documentation() - -function! s:show_documentation() - if (index(['vim','help'], &filetype) >= 0) - execute 'h '.expand('') - elseif (coc#rpc#ready()) - call CocActionAsync('doHover') - else - execute '!' . &keywordprg . " " . expand('') - endif -endfunction - -" Attempt to make pyright don't care about git root -autocmd FileType python let b:coc_root_patterns = ['.git', '.env'] - -" Highlight the symbol and its references when holding the cursor. -autocmd CursorHold * silent call CocActionAsync('highlight') - -" Symbol renaming. -nmap rn (coc-rename) - -" Formatting selected code. -xmap f (coc-format-selected) -nmap f (coc-format-selected) - - -" vim-multiple-cursors -let g:multi_cursor_use_default_mapping=0 - -" Default mapping -let g:multi_cursor_start_word_key = '' -let g:multi_cursor_select_all_word_key = '' -let g:multi_cursor_start_key = 'g' -let g:multi_cursor_select_all_key = 'g' -let g:multi_cursor_next_key = '' -let g:multi_cursor_prev_key = '' -let g:multi_cursor_skip_key = '' -let g:multi_cursor_quit_key = '' - -" vim-tmux-naviagtor -nnoremap -nnoremap -nnoremap -nnoremap - -" dadbod -xnoremap (DBExe) db#op_exec() -nnoremap (DBExe) db#op_exec() -nnoremap (DBExeLine) db#op_exec() . '_' - -xmap db (DBExe) -nmap db (DBExe) -omap db (DBExe) -nmap dbb (DBExeLine) - -autocmd FileType dbout setlocal nofoldenable - -if !empty(glob("~/.env.vim")) - source ~/.env.vim -endif - -" git-blame -nnoremap s :call gitblame#echo() - -" Disable annoying svelte indenting -let g:svelte_indent_script = 0 -let g:svelte_indent_style = 0 -- cgit v1.2.3