From 2453d8b26d8b684e95543ac8762f09f15abde00c Mon Sep 17 00:00:00 2001 From: Jean-Paul Abbuehl Date: Sun, 19 Nov 2023 11:29:25 +0100 Subject: [PATCH] fix keys and vimrc --- .bashrc | 3 + .vimrc | 1074 +++++++++---------------------------------------------- 2 files changed, 174 insertions(+), 903 deletions(-) diff --git a/.bashrc b/.bashrc index 12ef46e..e946439 100644 --- a/.bashrc +++ b/.bashrc @@ -74,3 +74,6 @@ if command -v powerline-daemon &>/dev/null; then POWERLINE_BASH_SELECT=1 source_if_exists "$HOME/.local/lib/python3.10/site-packages/powerline/bindings/bash/powerline.sh" fi + + +setxkbmap -option caps:swapescape \ No newline at end of file diff --git a/.vimrc b/.vimrc index d3e297e..2c217cb 100644 --- a/.vimrc +++ b/.vimrc @@ -1,706 +1,173 @@ -" 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 -" -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => General -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Sets how many lines of history VIM has to remember - -" Reinstall pluging (1 for yes, 0 for no) -let vim_plug_just_installed = 0 -set nocompatible -set history=500 - -" Python activate environment -let g:poetv_executables = ['poetry'] -let g:poetv_auto_activate = 1 - -" Enable filetype plugins -filetype plugin on -filetype indent on - -" Set to auto read when a file is changed from the outside -set autoread -au FocusGained,BufEnter * checktime - -" With a map leader it's possible to do extra key combinations -" like w saves the current file -let mapleader = "," - -" Fast saving -nmap w :w! - -" :W sudo saves the file -" (useful for handling the permission-denied error) -command! W execute 'w !sudo tee % > /dev/null' edit! - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => VIM user interface -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Set 7 lines to the cursor - when moving vertically using j/k +" ============================================================ +" Basic Settings +" ============================================================ +" Ensure Vim is not in compatibility mode with vi +set nocompatible +" Keep a large history of commands for easy recall +set history=500 +" Show the cursor's current position +set ruler +" Set the height of the command bar for better visibility +set cmdheight=2 +" Enable case-insensitive searching for convenience +set ignorecase +" Use smart case searching for more refined results +set smartcase +" Highlight search results to make them stand out +set hlsearch +" Incremental search improves search interaction +set incsearch +" Enable magic mode for powerful regular expressions +set magic +" Highlight matching brackets for easier code navigation +set showmatch +" Set the blink time for matching brackets +set mat=2 +" Avoid annoying error sounds +set noerrorbells +" Disable visual bells as well +set novisualbell +set t_vb= +" Set time to wait for a mapped sequence +set tm=500 +" Optimize performance by not redrawing during macros +set lazyredraw +" Enhance backspace functionality +set backspace=eol,start,indent +" Allow cursor to move past screen edge +set whichwrap+=<,>,h,l +" Use UTF-8 encoding for universal compatibility +set encoding=utf8 +" Support multiple file formats +set ffs=unix,dos,mac +" Set scroll offset for better context visibility set so=7 - -" Turn on the Wild menu, Hitting TAB in command mode will show possible completions above command line -set wildmenu -set wildchar= " Character for CLI expansion (TAB-completion) +" Use TAB for command line expansion +set wildchar= +" Ignore case in command line expansion for usability set wildignorecase -set wildmode=list:longest,full " Complete only until point of ambiguity - -" Ignore compiled files -set wildignore=*.o,*~,*.pyc -set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store -set wildignore+=*.jpg,*.jpeg,*.gif,*.png,*.gif,*.psd,*.o,*.obj,*.min.js -set wildignore+=*/bower_components/*,*/node_modules/* -set wildignore+=*/smarty/*,*/vendor/*,*/.sass-cache/*,*/log/*,*/tmp/*,*/build/*,*/ckeditor/*,*/doc/*,*/source_maps/*,*/dist/* - -"Always show current position -set ruler - -" Height of the command bar -set cmdheight=1 - -" A buffer becomes hidden when it is abandoned -set hid - -" Configure backspace so it acts as it should act -set backspace=eol,start,indent -set whichwrap+=<,>,h,l - -" Ignore case when searching -set ignorecase - -" When searching try to be smart about cases -set smartcase - -" Highlight search results -set hlsearch - -" Makes search act like search in modern browsers -set incsearch - -" Don't redraw while executing macros (good performance config) -set lazyredraw - -" For regular expressions turn magic on -set magic - -" Show matching brackets when text indicator is over them -set showmatch -" How many tenths of a second to blink when matching brackets -set mat=2 - -" No annoying sound on errors -set noerrorbells -set novisualbell -set t_vb= -set tm=500 - -" Add a bit extra margin to the left -set foldcolumn=1 - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Colors and Fonts -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Enable syntax highlighting -syntax enable - -" Enable 256 colors palette in Gnome Terminal -if $COLORTERM == 'gnome-terminal' - set t_Co=256 -endif - -syntax on - -" 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 utf8 as standard encoding and en_US as the standard language -set encoding=utf8 nobomb - -" Use Unix as the standard file type -set ffs=unix,dos,mac - -"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 -endif - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Files, backups and undo -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - -set nobackup -set nowb -set noswapfile - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Text, tab and indent related -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Use spaces instead of tabs -set expandtab - -" Be smart when using tabs ;) At start of line, inserts shiftwidth spaces, deletes shiftwidth spaces -set smarttab - -" 1 tab == 4 spaces -set shiftwidth=4 -set tabstop=4 -set softtabstop=2 " Tab key results in 2 spaces - -" Linebreak on 500 characters -set lbr -set tw=500 - -set ai "Auto indent -set si "Smart indent -set wrap "Wrap lines -set wrapscan " Searches wrap around end of file - -"""""""""""""""""""""""""""""" -" => Visual mode related -"""""""""""""""""""""""""""""" -" Visual mode pressing * or # searches for the current selection -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 - -" Smart way to move between windows -map j -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 - -"""""""""""""""""""""""""""""" -" => Status line -"""""""""""""""""""""""""""""" -" Always show the status line -set laststatus=2 - -" Format the status line -" 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() +" Exclude certain files and directories from command line expansion +set wildignore + +" ============================================================ +" UI Configurations +" ============================================================ +" Enable enhanced command line completion +set wildmenu +" Exclude more file types and directories in wildmenu +set wildignore+=*.o,*~,*.pyc,*.swp,*.zip +set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store +set wildignore+=*/node_modules/*,*/bower_components/* +" Set wildmenu completion behavior +set wildmode=list:longest,full +" Show line numbers for reference +set number +" Show relative line numbers for easier navigation +set relativenumber +" Highlight the current line for focus +set cursorline +" Always display the status line for information +set laststatus=2 +" Configure the folding column for code organization +set foldcolumn=1 + +" ============================================================ +" Filetype Indentation and Syntax Highlighting +" ============================================================ +" Enable filetype detection and plugins +filetype plugin on +" Enable filetype-based indentation +filetype indent on +" Turn on syntax highlighting for readability +syntax enable + +" Configure indentation for specific file types +autocmd FileType python setlocal expandtab shiftwidth=4 softtabstop=4 +autocmd FileType javascript setlocal expandtab shiftwidth=2 softtabstop=2 +autocmd FileType bash setlocal expandtab shiftwidth=4 softtabstop=4 +autocmd FileType yaml setlocal expandtab shiftwidth=2 softtabstop=2 +autocmd FileType typescript setlocal expandtab shiftwidth=2 softtabstop=2 + +" ============================================================ +" Leader Key and Mappings +" ============================================================ +" Define the leader key for custom shortcuts +let mapleader = "," +" Create a shortcut for quick saving +nmap w :w! +" Toggle spell checking +nmap ss :setlocal spell! +" Clear search highlighting quickly +nmap :noh + +" ============================================================ +" Backup, Undo, and File Reading +" ============================================================ +" Enable backup files +set backup +" Specify backup file directory +set backupdir=~/.vim/backups +" Exclude certain files from backups +set backupskip=/tmp/*,*.tmp +" Specify undo file directory for persistent undo +set undodir=~/.vim_runtime/temp_dirs/undodir +" Enable persistent undo +set undofile + +" ============================================================ +" Performance Optimization +" ============================================================ +" Configure plugin lazy loading for performance (specific configurations depend on the plugins used) + +" ============================================================ +" Plugin Configuration (Vim-Plug) +" ============================================================ +" Install Vim-Plug if it's not already present +if empty(glob('~/.vim/autoload/plug.vim')) + silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs + \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + autocmd VimEnter * PlugInstall | source $MYVIMRC 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= - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Helper functions -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Returns true if paste mode is enabled -function! HasPaste() - if &paste - return 'PASTE MODE ' - 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) - call feedkeys(":" . a:str) -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$", "", "") +" Begin plugin configurations +call plug#begin('~/.vim/plugged') +" Plugin declarations go here - 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 - - -" ============================================================================ -" Vim-plug initialization - -let fancy_symbols_enabled = 0 -let using_neovim = has('nvim') -let using_vim = !using_neovim - - -let vim_plug_path = expand('~/.vim/autoload/plug.vim') -if !filereadable(vim_plug_path) - echo "Installing Vim-plug..." - echo "" - silent !mkdir -p ~/.vim/autoload - silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim - let vim_plug_just_installed = 1 -endif - -" manually load vim-plug the first time -if vim_plug_just_installed - :execute 'source '.fnameescape(vim_plug_path) -endif - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => GUI related -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Disable scrollbars -set guioptions-=r -set guioptions-=R -set guioptions-=l -set guioptions-=L - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Turn persistent undo on -" means that you can undo even when you close a buffer/VIM -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -try - set undodir=~/.vim_runtime/temp_dirs/undodir - set undofile -catch -endtry - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Parenthesis/bracket -"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -vnoremap $1 `>a)` -vnoremap $2 `>a]` -vnoremap $3 `>a}` -vnoremap $$ `>a"` -vnoremap $q `>a'` -vnoremap $e `>a`` - -" Map auto complete of (, ", ', [ -inoremap $1 ()i -inoremap $2 []i -inoremap $3 {}i -inoremap $4 {o}O -inoremap $q ''i -inoremap $e ""i - -" useful binding when editing json -inoremap aa la -inoremap i o - -" autoclose with line break, useful for json -inoremap { {}O - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => General abbreviations -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -iab xdate =strftime("%d/%m/%y %H:%M:%S") - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Ack searching and cope displaying -" requires ack.vim - it's much better than vimgrep/grep -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Use the the_silver_searcher if possible (much faster than Ack) -if executable('ag') - let g:ackprg = 'ag --vimgrep --smart-case' -endif - -" When you press gv you Ack after the selected text -vnoremap gv :call VisualSelection('gv', '') - -" Open Ack and put the cursor in the right position -map g :Ack - -" When you press r you can search and replace the selected text -vnoremap r :call VisualSelection('replace', '') - -" When you search with Ack, display your results in cope by doing: -" To go to the next search result do: -" n -" To go to the previous search results do: -" p -map cc :botright cope -map co ggVGy:tabnew:set syntax=qfpgg -map n :cn -map p :cp - -" Make sure that enter is never overriden in the quickfix window -autocmd BufReadPost quickfix nnoremap - -" ============================================================================ -" Active plugins -call plug#begin("~/.vim/plugged") - -" Code commenter -Plug 'scrooloose/nerdcommenter' -" Class/module browser -Plug 'majutsushi/tagbar' -" A couple of nice colorschemes -Plug 'patstockwell/vim-monokai-tasty' -" Airline -Plug 'vim-airline/vim-airline' -Plug 'vim-airline/vim-airline-themes' -" Pending tasks list -Plug 'fisadev/FixedTaskList.vim' -" Completion from other opened files -Plug 'Shougo/context_filetype.vim' -" Automatically close parenthesis, etc -Plug 'jiangmiao/auto-pairs' -" Surround -Plug 'tpope/vim-surround' -" Indent text object -Plug 'michaeljsmith/vim-indent-object' -" Indentation based movements -Plug 'jeetsukumaran/vim-indentwise' -" Better language packs +" Language support for YAML, JSON, Python, TypeScript, Bash, JavaScript Plug 'sheerun/vim-polyglot' -" Git integration -Plug 'tpope/vim-fugitive' -" Consoles as buffers (neovim has its own consoles as buffers) -Plug 'rosenfeld/conque-term' -" Asynchrinous lint engine -Plug 'dense-analysis/ale' -" Comment/uncomment lines -Plug 'tpope/vim-commentary' -" Interactive debugger -Plug 'puremourning/vimspector' -" NERDTree -Plug 'preservim/nerdtree' -" Add indent visualization -Plug 'Yggdroot/indentLine' - -Plug 'pangloss/vim-javascript' Plug 'leafgarland/typescript-vim' +Plug 'pangloss/vim-javascript' Plug 'peitalin/vim-jsx-typescript' -Plug 'styled-components/vim-styled-components', { 'branch': 'main' } -Plug 'jparise/vim-graphql' - -Plug 'NLKNguyen/papercolor-theme' - -" Typescript support Plug 'HerringtonDarkholme/yats.vim' +" Visualize indent across languages +Plug 'Yggdroot/indentLine' -call plug#end() +" Git integration +Plug 'tpope/vim-fugitive' -set background=dark -colorscheme PaperColor +" Interactive Debugger +Plug 'puremourning/vimspector' +" Linting automatically +Plug 'dense-analysis/ale' -" ============================================================================ -" Install plugins the first time vim runs +call plug#end() -if vim_plug_just_installed - echo "Installing Bundles, please ignore key map error messages" - :PlugInstall +" ============================================================ +" Terminal and Color Support +" ============================================================ +" Enable 256 color support for certain terminals +if $COLORTERM == 'gnome-terminal' || $TERM_PROGRAM == 'iTerm.app' + set t_Co=256 endif +" ============================================================ +" Additional Custom Functions +" ============================================================ +" Custom functions and key mappings for enhanced functionality -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Nerd Tree -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -let g:NERDTreeWinPos = "right" -let NERDTreeShowHidden=0 -let NERDTreeIgnore = ['\.pyc$', '__pycache__'] -let g:NERDTreeWinSize=35 -map nn :NERDTreeToggle -map nb :NERDTreeFromBookmark -map nf :NERDTreeFind - -" Start NERDTree when Vim is started without file arguments. -autocmd StdinReadPre * let s:std_in=1 -autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NERDTree | endif - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => 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 = '' - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Ale (syntax checker and linter) -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -let g:ale_linters = { -\ 'javascript': ['eslint'], -\ 'typescript': ['eslint'], -\ 'python': ['flake8'], -\ 'go': ['go', 'golint', 'errcheck'], -\ 'sh': ['ShellCheck'] -\} - -let g:ale_fix_on_save = 1 - -nnoremap ]r :ALENextWrap " move to the next ALE warning / error -nnoremap [r :ALEPreviousWrap " move to the previous ALE warning / error - -nmap a (ale_next_wrap) - -" Disabling highlighting -let g:ale_set_highlights = 1 - -" Only run linting when saving the file -" let g:ale_lint_on_text_changed = 'never' -let g:airline#extensions#ale#enabled = 1 - -" Only run linting when saving the file -"" "let g:ale_lint_on_text_changed = 'never' -let g:ale_lint_on_enter = 1 - -" automatic imports from external modules -let g:ale_completion_autoimport = 1 - -nmap (ale_previous_wrap) -nmap (ale_next_wrap) - -let g:ale_set_loclist = 0 -let g:ale_set_quickfix = 1 -let g:ale_open_list = 1 -let g:ale_keep_list_window_open = 1 - -" ============================================================================ -" Set Theme - -let g:vim_monokai_tasty_italic = 1 -let g:lightline = { - \ 'colorscheme': 'onedark', - \ } -let g:airline_theme='onedark' - -" ============================================================================ -" Vim settings and mappings -" You can edit them as you wish -autocmd Filetype json setlocal ts=2 sw=2 expandtab -autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab -autocmd FileType netrw setl bufhidden=delete -let g:indentLine_char = '⦙' -set path+=** " provide tab-completion for all file-related tasks - -set ls=2 " Show always status bar -" better backup, swap and undos storage for vim (nvim has nice ones by -" default) - -" remove ugly vertical lines on window division -set fillchars+=vert:\ - -" fix problems with uncommon shells (fish, xonsh) and plugins running commands -" (neomake, ...) - -" Ability to add python breakpoints -" (I use ipdb, but you can change it to whatever tool you use for debugging) - -" File browsing {{{ -let g:netrw_banner=0 " disable annoying banner -let g:netrw_browse_split=4 " open in prior window -let g:netrw_altv=1 " open splits to the right -let g:netrw_liststyle=3 " tree view -let g:netrw_list_hide=netrw_gitignore#Hide() -let g:netrw_list_hide.=',\(^\|\s\s\)\zs\.\S\+' - -" Set some junk {{{ -set autoindent " Copy indent last line when starting new line -set cursorline " Highlight current line -set showmatch " show matching parts of parenthese, brackets, etc.. -set diffopt=filler " Add vertical spaces to keep right and left aligned -set diffopt+=iwhite " Ignore whitespace changes (focus on code changes) -set esckeys " Allow cursor keys in insert mode -set foldlevel=99 " Open all folds by default -set foldmethod=indent " Indent are used to specify folds -set foldminlines=0 " Allow folding single lines -set foldnestmax=5 " Set max fold nesting level -set formatoptions= -set formatoptions+=c " Format comments -set formatoptions+=r " Continue comments by default -set formatoptions+=o " Make comment when using o or O from comment line -set formatoptions+=q " Format comments with gq -set formatoptions+=n " Recognize numbered lists -set formatoptions+=2 " Use indent from 2nd line of a paragraph -set formatoptions+=l " Don't break lines that are already long -set formatoptions+=1 " Break before 1-letter words -set gdefault " By default add g flag to search/replace. Add g to toggle -set hidden " When a buffer is brought to foreground, remember undo history and marks -set lispwords+=defroutes " Compojure -set lispwords+=defpartial,defpage " Noir core -set lispwords+=defaction,deffilter,defview,defsection " Ciste core -set lispwords+=describe,it " Speclj TDD/BDD -set modelines=0 " Disable modelines a security precaution -set nomodeline -set nojoinspaces " Only insert single space after a '.', '?' and '!' with a join command -set noshowmode " Don't show the current mode (airline.vim takes care of us) -set nostartofline " Don't reset cursor to start of line when moving around -set nowrap " Do not wrap lines -set nu " Enable line numbers -set ofu=syntaxcomplete#Complete " Set omni-completion method -set regexpengine=1 " Use the old regular expression engine (it's faster for certain language syntaxes) -set report=0 " Show all changes -set shell=/bin/bash " Use /bin/bash for executing shell commands -set shiftwidth=2 " The # of spaces for indenting -set shortmess=atI " Don't show the intro message when starting vim -set showtabline=2 " Always show tab bar -set sidescrolloff=3 " Start scrolling three columns before vertical border of window -set splitbelow " New window goes below -set splitright " New windows goes right -set suffixes=.bak,~,.swp,.swo,.o,.d,.info,.aux,.log,.dvi,.pdf,.bin,.bbl,.blg,.brf,.cb,.dmg,.exe,.ind,.idx,.ilg,.inx,.out,.toc,.pyc,.pyd,.dll -set switchbuf="" -set title " Show the filename in the window titlebar -set ttyfast " Send more characters at a given time -set ttymouse=xterm " Set mouse type to xterm -set noundofile " Persistent Undo -set viminfo=%,'9999,s512,n~/.vim/viminfo " Restore buffer list, marks are remembered for 9999 files, registers up to 512Kb are remembered -set visualbell " Use visual bell instead of audible bell (annnnnoying) -set winminheight=0 " Allow splits to be reduced to a single line -set relativenumber " Show relative line numbers -set number " Show current line number -" }}} - - -" FastEscape {{{ -" Speed up transition from modes -" Fine tune timeout len https://stackoverflow.com/questions/26829086/key-specific-timeoutlen-in-vim +" Speed up mode transitions if ! has('gui_running') set ttimeoutlen=10 augroup FastEscape @@ -709,233 +176,34 @@ if ! has('gui_running') au InsertLeave * set timeoutlen=1000 augroup END endif -" }}} - - -" Get output of shell commands {{{ -command! -nargs=* -complete=shellcmd R new | setlocal buftype=nofile bufhidden=hide noswapfile | r ! -" }}} -" Remap :W to :w {{{ -command! W write -" }}} - - -" Better mark jumping (line + col) {{{ -nnoremap ' ` -" }}} +" Autoclose brackets with line breaks, useful for JSON +inoremap { {}O -nnoremap \\ :noh +" Abbreviations for faster typing +iab xdate =strftime("%d/%m/%y %H:%M:%S") -" Snippets -nnoremap ,html :-1read $HOME/.vim/.skeleton.html3jwf>a +" Bindings for efficient JSON editing +inoremap aa la +inoremap i o -" Move between splits -"split navigations +" Key mappings to move between window splits nnoremap nnoremap nnoremap nnoremap -" clear empty spaces at the end of lines on save of python files -autocmd BufWritePre *.py :%s/\s\+$//e - - -" Python indentation -au BufNewFile,BufRead *.py - \ set tabstop=4 | - \ set softtabstop=4 | - \ set shiftwidth=4 | - \ set textwidth=79 | - \ set expandtab | - \ set autoindent | - \ set fileformat=unix - -let python_highlight_all = 1 - -" Webdevelopment indentation -au BufNewFile,BufRead *.js,*.html,*.css - \ set tabstop=2 | - \ set softtabstop=2 | - \ set shiftwidth=2 - -" Deoplete ----------------------------- -let g:deoplete#enable_at_startup = 1 - -" Jedi-vim ------------------------------ - -" Disable autocompletion (using deoplete instead) -let g:jedi#auto_initialization = 0 -let g:jedi#completions_enabled = 0 -let g:jedi#use_tabs_not_buffers = 0 -let g:jedi#popup_select_first = 0 -let g:jedi#popup_on_dot = 0 - -" All these mappings work only for python code: -" Go to definition -let g:jedi#goto_command = ',d' -" Find ocurrences -let g:jedi#usages_command = ',o' -" Find assignments -let g:jedi#goto_assignments_command = ',a' -" Go to definition in new tab -nmap ,D :tab split:call jedi#goto() - - -" Airline ------------------------------ - -let g:airline_powerline_fonts = 1 -let g:airline_theme = 'bubblegum' -let g:airline#extensions#whitespace#enabled = 1 - -" Fancy Symbols!! - -if fancy_symbols_enabled - let g:webdevicons_enable = 1 - - " custom airline symbols - if !exists('g:airline_symbols') - let g:airline_symbols = {} - endif - let g:airline_left_sep = '' - let g:airline_left_alt_sep = '' - let g:airline_right_sep = '' - let g:airline_right_alt_sep = '' - let g:airline_symbols.branch = '⭠' - let g:airline_symbols.readonly = '⭤' - let g:airline_symbols.linenr = '⭡' -else - let g:webdevicons_enable = 0 -endif - -"""""""""""""""""""""""""""""" -" => Python section -"""""""""""""""""""""""""""""" -let python_highlight_all = 1 -au FileType python syn keyword pythonDecorator True None False self - -au BufNewFile,BufRead *.jinja set syntax=htmljinja -au BufNewFile,BufRead *.mako set ft=mako - -au FileType python map F :set foldmethod=indent - -au FileType python inoremap $r return -au FileType python inoremap $i import -au FileType python inoremap $p print -au FileType python inoremap $f # --- a -au FileType python map 1 /class -au FileType python map 2 /def -au FileType python map C ?class -au FileType python map D ?def - -let g:vimspector_enable_mappings = 'HUMAN' -let g:vimspector_install_gadgets = [ 'debugpy', 'vscode-go', 'vscode-bash-debug' ] -au FileType python map :w:!python % - -"""""""""""""""""""""""""""""" -" => JavaScript section -""""""""""""""""""""""""""""""" -au FileType javascript call JavaScriptFold() -au FileType javascript setl fen -au FileType javascript setl nocindent - -au FileType javascript imap $log();hi -au FileType javascript imap alert();hi - -au FileType javascript inoremap $r return -au FileType javascript inoremap $f // --- PHFP2xi - -function! JavaScriptFold() - setl foldmethod=syntax - setl foldlevelstart=1 - syn region foldBraces start=/{/ end=/}/ transparent fold keepend extend - - function! FoldText() - return substitute(getline(v:foldstart), '{.*', '{...}', '') - endfunction - setl foldtext=FoldText() -endfunction - -let g:lightline = { - \ 'colorscheme': 'onedark', - \ } - - -"""""""""" -" => Bash section -"""""""""" - -" lint bash script - - -" execute current line -nmap :exec '!'.getline('.') - -"" Currently return outputs to file -vnoremap :'>put =system(join(getline('''<','''>'),\"\n\").\"\n\") - -"""""""" -" Yaml -""""""""" -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' - - -"""""" -" Typescript -""""""" - -set re=0 -if executable('prettier') - autocmd FileType javascript setlocal formatprg=prettier\ --stdin\ --parser\ flow - autocmd FileType typescript,typescript.tsx setlocal formatprg=prettier\ --stdin\ --parser\ typescript - autocmd FileType json setlocal formatprg=prettier\ --stdin\ --parser\ json - - autocmd FileType css,less setlocal formatprg=prettier\ --parser\ css - autocmd FileType html setlocal formatprg=prettier\ --parser\ html - - autocmd FileType markdown setlocal formatprg=prettier\ --parser\ markdown - autocmd FileType yaml setlocal formatprg=prettier\ --parser\ yaml -endif -" command is gggqG to autoformat - - -"""" -" Formatter -""""" -" -nmap aj :ALENext -nmap ak :ALEPrevious - -autocmd FileType javascript map :ALEGoToDefinition -autocmd FileType typescript map :ALEGoToDefinition -autocmd FileType typescriptreact map :ALEGoToDefinition -nnoremap K :ALEHover -nnoremap qf :ALECodeAction -vnoremap qf :ALECodeAction -let js_fixers = ['eslint'] - -let g:ale_fixers = { -\ '*': ['remove_trailing_lines', 'trim_whitespace'], -\ 'javascript': js_fixers, -\ 'javascript.jsx': js_fixers, -\ 'typescript': js_fixers, -\ 'typescriptreact': js_fixers, -\ 'css': ['prettier'], -\ 'json': ['prettier'], -\ 'yaml': ['prettier'] -\} - -let g:ale_sign_error = "🐛" -let g:ale_sign_warning = "⚠️" -let g:ale_sign_info = "ℹ" +" ============================================================ +" Auto-commands and Fine Tuning +" ============================================================ +" Additional auto-commands and tweaks based on personal preferences +" ============================================================ +" Language-Specific Settings +" ============================================================ +" Additional settings for specific programming languages -"""" -" quickfix shortcut -""""" +" ============================================================ +" End of .vimrc +" ============================================================ -map :cn -map :cp