-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.vimrc
More file actions
130 lines (108 loc) · 3.96 KB
/
.vimrc
File metadata and controls
130 lines (108 loc) · 3.96 KB
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
set number relativenumber " Line number display
set expandtab " Use spaces instead of tabs
set tabstop=4 " Number of spaces a tab counts for
set shiftwidth=4 " Number of spaces for each step of autoindent
set clipboard=unnamed " Use system clipboard for yanking and pasting
set autoindent " Enable autoindent
set smartindent " Smart indent for Python TODO what is this?
set showmatch " Show matching brackets
" set mouse=a " Enable mouse in all modes TODO do I need this?
set wildmenu " Commnad-line completion
set encoding=utf-8 " Required for coc.nvim in Vim
set updatetime=300 " For a smoother experience
" Disable backup files to avoid issues with language servers
set nobackup
set nowritebackup
" Cursor shape configuration
let &t_SI = "\e[6 q" " Use vertical bar cursor in insert mode
let &t_EI = "\e[2 q" " Use block cursor in normal mode
" Bracketed paste support (fixes È characters when pasting in tmux)
if &term =~ '^\%(screen\|tmux\)'
let &t_BE = "\e[?2004h" " Enable bracketed paste mode
let &t_BD = "\e[?2004l" " Disable bracketed paste mode
let &t_PS = "\e[200~" " Paste start marker
let &t_PE = "\e[201~" " Paste end marker
endif
" Filetype-specific settings
" Enable filetype detection
filetype plugin indent on
" Settings
augroup filetype_settings
autocmd!
" Python settings
autocmd FileType python setlocal
\ tabstop=4
\ softtabstop=4
\ shiftwidth=4
\ expandtab
\ autoindent
\ fileformat=unix
\ colorcolumn=80 " For PEP8
" Markdown settings
autocmd FileType markdown setlocal
\ tabstop=2
\ softtabstop=2
\ shiftwidth=2
\ expandtab
\ autoindent
" JSON settings
autocmd FileType JSON setlocal
\ tabstop=2
\ softtabstop=2
\ shiftwidth=2
\ expandtab
\ autoindent
augroup END
" Plugins with Vim-Plug
call plug#begin()
" Theme plugin
Plug 'ayu-theme/ayu-vim'
" Other plugins
Plug 'neoclide/coc.nvim', {'branch': 'release'} " VSCode-like intellisense
Plug 'tpope/vim-commentary' " Code commenting
Plug 'tpope/vim-surround' " Surround text with quotes, parens, etc.
call plug#end()
" Theme configuration
set termguicolors
let ayucolor="mirage"
colorscheme ayu
" coc.nvim configuration - basic settings
" Tab for trigger completion, completion confirm, snippet expand and jump
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#pum#next(1) :
\ CheckBackspace() ? "\<Tab>" :
\ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
" Make <CR> auto-select the first completion item
inoremap <silent><expr> <cr> coc#pum#visible() ? coc#pum#confirm() : "\<CR>"
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion
inoremap <silent><expr> <c-space> coc#refresh()
" Navigation mappings
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Diagnostic navigation
nmap <silent><nowait> [g <Plug>(coc-diagnostic-prev)
nmap <silent><nowait> ]g <Plug>(coc-diagnostic-next)
" Use K to show documentation in preview window
nnoremap <silent> K :call ShowDocumentation()<CR>
function! ShowDocumentation()
if CocAction('hasProvider', 'hover')
call CocActionAsync('doHover')
else
call feedkeys('K', 'in')
endif
endfunction
autocmd CursorHold * silent call CocActionAsync('highlight') " Symbol highlight
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} " Status line
" Symbol renaming
nmap <leader>rn <Plug>(coc-rename)
" Quick fix for current line
nmap <leader>qf <Plug>(coc-fix-current)
" Organize imports command
command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport')