-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc
156 lines (140 loc) · 4.35 KB
/
.vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
set nocp
set number
set ts=4
set sts=4
set sw=4
set expandtab
set bs=2
set scrolloff=3
set incsearch
set ignorecase
set linebreak
set pastetoggle=,tp
set directory=$HOME/.vim/swapfiles/
set lcs=trail:-,extends:>,tab:>-,eol:$
set vb t_vb=
set splitright
let mapleader = ","
inoremap jj <Esc>
nnoremap j gj
nnoremap k gk
nnoremap <C-h> :bprevious<CR>
nnoremap <C-l> :bnext<CR>
nnoremap <C-s> :set hlsearch!<CR>
nnoremap <Leader>tw :set wrap!<CR>
nnoremap <Leader>tl :set list!<CR>
nnoremap <CR> o<Esc>
nnoremap <Leader>ev :e $MYVIMRC<CR>
nnoremap <Leader>sv :source $MYVIMRC<CR>
vnoremap < <gv
vnoremap > >gv
" https://github.com/junegunn/vim-plug
" Automatic installaion of vim-plug and swapfiles creation
if empty(glob('~/.vim/autoload/plug.vim'))
silent !mkdir -p ~/.vim/swapfiles
silent !mkdir -p ~/.vim/autoload
silent !curl -fLo ~/.vim/autoload/plug.vim
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall
endif
call plug#begin('~/.vim/plugged')
Plug 'junegunn/fzf'
"Plug 'ziglang/zig.vim'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-eunuch' "useful for :Rename, :Move
Plug 'scrooloose/nerdcommenter'
Plug 'ntpeters/vim-better-whitespace'
Plug 'lambdalisue/suda.vim'
Plug 'nvim-tree/nvim-web-devicons'
"colorschemes
Plug 'EvitanRelta/vim-colorschemes'
"Plug 'navarasu/onedark.nvim'
"Plug 'sainnhe/sonokai'
"Plug 'rktjmp/lush.nvim'
"Plug 'ViViDboarder/wombat.nvim'
"Plug 'Mofiqul/vscode.nvim'
"Plug 'EdenEast/nightfox.nvim'
"Plug 'tiagovla/tokyodark.nvim'
"Plug 'mhinz/vim-grepper'
if has('nvim')
Plug 'neovim/nvim-lspconfig'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
" similar plugins, mostly barebones, render all buffers as visual "tabs", with some differences like sorting
"Plug 'ap/vim-buftabline'
Plug 'romgrk/barbar.nvim'
set signcolumn=number
set updatetime=300
endif
call plug#end()
" https://cj.rs/blog/git-ls-files-is-faster-than-fd-and-find/
" https://github.com/junegunn/fzf/blob/master/README-VIM.md
" https://github.com/junegunn/fzf/issues/31
function! FZFExecute()
" Remove trailing new line to make it work with tmux splits
let directory = substitute(system('git rev-parse --show-toplevel'), '\n$', '', '')
if !v:shell_error
call fzf#run({'sink': 'e', 'dir': directory, 'source': 'git ls-files -c --exclude-standard', 'window': { 'width': 0.9, 'height': 0.6 } })
else
FZF
endif
endfunction
command! FZFExecute call FZFExecute()
function! FZFCWDExecute()
" Remove trailing new line to make it work with tmux splits
if !v:shell_error
call fzf#run({'sink': 'e', 'dir': '.', 'window': { 'width': 0.9, 'height': 0.6 } })
else
FZF
endif
endfunction
command! FZFCWDExecute call FZFCWDExecute()
let $FZF_DEFAULT_COMMAND = 'fd --type f --exclude .git'
nnoremap <C-p> :FZFExecute<CR>
nnoremap <C-.> :FZFCWDExecute<CR>
let g:vim_markdown_folding_disabled = 1
let g:vim_markdown_new_list_item_indent = 0
let g:strip_whitespace_on_save = 1
let g:strip_whitespace_confirm = 0
"colorscheme terafox
"colorscheme wombat256mod
"colorscheme wombat_classic
colorscheme onedark
" https://stackoverflow.com/a/7616332/198348
highlight Normal guibg=black guifg=white
if has('termguicolors')
set termguicolors
endif
if !has('nvim')
finish
endif
lua << EOF
require'lspconfig'.pyright.setup{}
require'lspconfig'.clangd.setup{}
require'barbar'.setup {
auto_hide = true,
}
-- https://github.com/nvim-treesitter/nvim-treesitter
require'nvim-treesitter.configs'.setup {
ensure_installed = { "java", "cpp", "rust", "python", "javascript", "jsonc", "typescript", "tsx", "bash", "markdown", "vim", "lua" },
highlight = {
enable = true,
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = "vim"
}, incremental_selection = {
enable = true,
keymaps = {
init_selection = "gnn",
node_incremental = "grn",
scope_incremental = "grc",
node_decremental = "grm",
},
},
}
EOF
nnoremap <C-h> :BufferPrevious<CR>
nnoremap <C-l> :BufferNext<CR>
nnoremap <Leader>bc :BufferClose<CR>
nnoremap <Leader>bw :BufferWipeout<CR>