aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOxbian <got.dacs@slmail.me>2023-06-19 00:20:11 +0200
committerOxbian <got.dacs@slmail.me>2023-06-19 00:20:11 +0200
commitced35c5dccc7c4b1cbc996bf98a7cf19df2602e8 (patch)
tree13032547ae4a5583973986f7ebc43acc73e26264
downloadvimrc-ced35c5dccc7c4b1cbc996bf98a7cf19df2602e8.tar.gz
vimrc-ced35c5dccc7c4b1cbc996bf98a7cf19df2602e8.zip
Init dotfiles
-rw-r--r--.vim/keymaps.vim27
-rw-r--r--.vim/options.vim165
-rw-r--r--.vim/plugins.vim108
-rw-r--r--.vimrc4
-rw-r--r--readme.md56
5 files changed, 360 insertions, 0 deletions
diff --git a/.vim/keymaps.vim b/.vim/keymaps.vim
new file mode 100644
index 0000000..794f84b
--- /dev/null
+++ b/.vim/keymaps.vim
@@ -0,0 +1,27 @@
+"""""""""""""""""""""""""""""
+" Keymaps
+"""""""""""""""""""""""""""""
+
+" Window movement
+noremap <C-j> <C-w>j
+noremap <C-k> <C-w>k
+noremap <C-l> <C-w>l
+noremap <C-h> <C-w>h
+
+" Remove highlighting
+nnoremap <leader>h :nohlsearch<CR>
+
+" Save file
+nnoremap <C-s> :w!<CR>
+
+" NerdTree
+nnoremap <C-f> :NERDTreeToggle<CR>
+
+" GitGutter
+let g:gitgutter_enabled=1 " Enable by default gitgutter
+nnoremap <leader>d :GitGutterToggle<CR>
+nnoremap <leader>hs :GitGutterStageHunk<CR>
+nnoremap <leader>hu :GitGutterUndoHunk<CR>
+nnoremap <leader>hp :GitGutterPreviewHunk<CR>
+
+
diff --git a/.vim/options.vim b/.vim/options.vim
new file mode 100644
index 0000000..29f9f2c
--- /dev/null
+++ b/.vim/options.vim
@@ -0,0 +1,165 @@
+" Mapping
+let mapleader =" " " Set mapleader
+
+" Search options
+set incsearch " Search for partial typed match
+set ignorecase " Search not case sensitive
+set smartcase " Search for pattern if contains uppercase
+set hlsearch " Highlight all match search pattern
+
+" Graphics options
+syntax on " Show syntax color
+set background=dark
+colorscheme onedark
+set number " Show line number
+set cursorline " Select the current line
+set showmatch " Show matching brackets when overred
+set laststatus =2 " Fix for tabline
+set noshowmode " Disable the -- INSERTION -- default comment
+set so =7 " Set 7 lines to the cursor - when moving vertically
+set cmdheight=1 " Height of the command bar
+set regexpengine=0 " Set regular expression engine automatically
+
+" Mouse options
+set mouse = "a" " Allow the mouse to do all the editing
+set ruler " Show the cursor position on the tagline
+
+" Indent options
+set softtabstop =4 " Size of a tab
+set shiftwidth =4 " Number of space for each indent
+set noexpandtab " Vim will automatically use tab
+set smarttab " Add tab smartly
+set autoindent " Automatically set the indent of a new line
+set smartindent " Do clever indenting
+
+" Automatic options
+set autowrite " Automatically write the file on certain actions
+set autoread " Automatically read extern changes on the file
+
+" System
+if has('unnamedplus') " ALlow OS & vim clipboard sync
+ set clipboard = "unnamedplus"
+endif
+set undofile " Save undo history
+set history =500 " Max line vim remember
+set updatetime=500 " Delay before vim write swap file, lower better for gitgutter
+
+" Autocomplete
+set completeopt = "menuone,noselect" " Show a pop up for command completion
+set wildmenu " Turn on wildmenu
+
+" Avoid garbled characters in Chinese language windows OS
+let $LANG='en'
+set langmenu=en
+source $VIMRUNTIME/delmenu.vim
+source $VIMRUNTIME/menu.vim
+
+" 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 hid " A buffer becomes hidden when it is abandoned
+
+" Configure backspace so it acts as it should act
+set backspace=eol,start,indent
+set whichwrap+=<,>,h,l
+
+" Don't redraw while executing macros (good performance config)
+set lazyredraw
+
+" For regular expressions turn magic on
+set magic
+
+" 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
+
+" 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
+
+" Set utf8 as standard encoding and en_US as the standard language
+set encoding=utf8
+
+" Use Unix as the standard file type
+set ffs=unix,dos,mac
+
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" => Files, backups and undo
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Turn backup off, since most stuff is in SVN, git etc. anyway...
+set nobackup
+set nowb
+set noswapfile
+
+" Close the current buffer
+map <leader>bd :Bclose<cr>:tabclose<cr>gT
+
+" Close all the buffers
+map <leader>ba :bufdo bd<cr>
+
+map <leader>l :bnext<cr>
+map <leader>h :bprevious<cr>
+
+" Useful mappings for managing tabs
+map <leader>tn :tabnew<cr>
+map <leader>to :tabonly<cr>
+map <leader>tc :tabclose<cr>
+map <leader>tm :tabmove
+map <leader>t<leader> :tabnext<cr>
+
+" Let 'tl' toggle between this and the last accessed tab
+let g:lasttab = 1
+nmap <leader>tl :exe "tabn ".g:lasttab<CR>
+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 <leader>te :tabedit <C-r>=escape(expand("%:p:h"), " ")<cr>/
+
+" Switch CWD to the directory of the open buffer
+map <leader>cd :cd %:p:h<cr>:pwd<cr>
+
+" 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
+
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" => Spell checking
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Pressing ,ss will toggle and untoggle spell checking
+map <leader>ss :setlocal spell!<cr>
+
+" Shortcuts using <leader>
+map <leader>sn ]s
+map <leader>sp [s
+map <leader>sa zg
+map <leader>s? z=
+
diff --git a/.vim/plugins.vim b/.vim/plugins.vim
new file mode 100644
index 0000000..b873d58
--- /dev/null
+++ b/.vim/plugins.vim
@@ -0,0 +1,108 @@
+""""""""""""""""""""""""""
+" Plugins
+""""""""""""""""""""""""""
+" Install vim-plug if not found
+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
+endif
+
+" Run PlugInstall if there are missing plugins
+autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
+ \| PlugInstall --sync | source $MYVIMRC
+\| endif
+
+call plug#begin('~/.vim/plugged')
+
+" UI & Themes
+Plug 'joshdick/onedark.vim' " Onedark themes for vim
+Plug 'vim-airline/vim-airline' " Vim statusline
+Plug 'preservim/nerdtree' " Filetree in vim
+Plug 'ryanoasis/vim-devicons' " Icons for vim
+
+" Git integration
+Plug 'tpope/vim-fugitive' " Git commands & informations
+Plug 'airblade/vim-gitgutter' " Git diff
+
+" Autocompletion, linter, syntax
+Plug 'dense-analysis/ale' " Swiss-knife for all this
+
+call plug#end()
+
+filetype plugin indent on " Allow filetype detection, plugins, indentation
+
+"""""""""""""""""""""""""
+" Configuration
+"""""""""""""""""""""""""
+" VIM airline
+let g:airline_theme='onedark' " Status line color & configuration
+
+if !exists('g:airline_symbols')
+ let g:airline_symbols = {}
+endif
+let g:airline_symbols.colnr = ' ㏇:'
+let g:airline_symbols.colnr = ' β„…:'
+let g:airline_symbols.crypt = 'πŸ”’'
+let g:airline_symbols.linenr = '☰'
+let g:airline_symbols.linenr = ' ␊:'
+let g:airline_symbols.linenr = ' ␀:'
+let g:airline_symbols.linenr = 'ΒΆ'
+let g:airline_symbols.maxlinenr = ''
+let g:airline_symbols.maxlinenr = '㏑'
+let g:airline_symbols.branch = 'βŽ‡'
+let g:airline_symbols.paste = 'ρ'
+let g:airline_symbols.paste = 'Þ'
+let g:airline_symbols.paste = 'βˆ₯'
+let g:airline_symbols.spell = 'Ꞩ'
+let g:airline_symbols.notexists = 'Ι†'
+let g:airline_symbols.notexists = 'βˆ„'
+let g:airline_symbols.whitespace = 'Ξ'
+let g:airline#extensions#ale#enabled = 1 " Allow ALE to use status line
+
+" ALE
+let g:ale_linters = {
+\ 'javascript': ['eslint'],
+\ 'python': ['flake8'],
+\ }
+
+let g:ale_completion_enabled = 1
+let g:ale_completion_symbols = {
+\ 'text': 'ξ˜’',
+\ 'method': '',
+\ 'function': '',
+\ 'constructor': '',
+\ 'field': 'ο‚­',
+\ 'variable': 'ο„‘',
+\ 'class': '',
+\ 'interface': 'ο‡ ',
+\ 'module': '',
+\ 'property': 'ο‚­',
+\ 'unit': 'unit',
+\ 'value': 'val',
+\ 'enum': 'ο‡ ',
+\ 'keyword': 'keyword',
+\ 'snippet': 'ξ˜’',
+\ 'color': 'color',
+\ 'file': 'ο€­',
+\ 'reference': 'ref',
+\ 'folder': 'ξ—Ώ',
+\ 'enum member': '',
+\ 'constant': 'ο„‘',
+\ 'struct': '',
+\ 'event': 'event',
+\ 'operator': 'ο‚­',
+\ 'type_parameter': 'type param',
+\ '<default>': 'v'
+\ }
+
+" NerdTree
+let NERDTreeShowHidden=1 " Show hidden files
+" Close the tab if NERDTree is the only window remaining in it.
+autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
+" If another buffer tries to replace NERDTree, put it in the other window, and bring back NERDTree.
+autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 |
+ \ let buf=bufnr() | buffer# | execute "normal! \<C-W>w" | execute 'buffer'.buf | endif
+" If more than one window and previous buffer was NERDTree, go back to it.
+autocmd BufEnter * if bufname('#') =~# "^NERD_tree_" && winnr('$') > 1 | b# | endif
+let g:plug_window = 'noautocmd vertical topleft new' " Stop crash if vimplug command called on the nerdtree window
+
diff --git a/.vimrc b/.vimrc
new file mode 100644
index 0000000..2906e97
--- /dev/null
+++ b/.vimrc
@@ -0,0 +1,4 @@
+" Vim configuration, do not delete
+source ~/.vim/plugins.vim
+source ~/.vim/options.vim
+source ~/.vim/keymaps.vim
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..a8e74fd
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,56 @@
+# VIM
+
+This repo contains my vim configuration, hope it will be usefull for you.
+
+## Installation
+
+You will need `vim` and `git` to be able to use this config.
+
+Normally if you run the `install.sh` script it will work, but if you have a problem, try to install vim plug and check if your problem is solved.
+
+```bash
+curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
+ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
+```
+
+Oh and remove neovim, it make some problems with vim.
+
+## Plugins
+
+This config has just the necessarry plugins installed:
+
+- [Vim gitgutter](https://github.com/airblade/vim-gitgutter) to see diff between files with git.
+- [Vim fugitive](https://github.com/tpope/vim-fugitive) to be able to use some powerful git commands in git.
+-
+## Command & keybinds
+
+### General
+
+- `Ctrl+h` move to the left window
+- `Ctrl+j` move to the bottom window
+- `Ctrl+k` move to the upper window
+- `Ctrl+l` move to the right window
+- `<leader>h` remove highligthing
+
+### NerdTree
+
+For help, use `:help NERDTree`.
+Keybinds:
+- `Ctrl+f` open or close the nerdtree window
+
+### Vim Gutter
+
+For help, use `:help gitgutter`.
+Keybinds:
+- `[c` & `]c` to jump between hunks,
+- `<leader>hp` to preview hunk,
+- `<leader>hs` to stage hunk,
+- `<leader>hu` to undo hunk,
+- `<leader>d` to toggle GitGutter.
+
+Hunks are the difference between your file and the git file.
+
+### Vim Fugitive
+
+For help, use `:help fugitive`.
+
ArKa projects. All rights to me, and your next child right arm.