summaryrefslogtreecommitdiff
path: root/vim/.vimrc
blob: fb5c55eee86c6d21e6a74a7a6530ba98655b81e0 (plain)
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
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
call plug#begin('~/.vim/plugged')
Plug 'itchyny/lightline.vim'
Plug 'mattn/emmet-vim'
Plug 'liuchengxu/vim-which-key'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'kamil-stachowski/flatwhite-vim'
Plug 'prabirshrestha/vim-lsp'
Plug 'mattn/vim-lsp-settings'
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/asyncomplete-lsp.vim'
Plug 'tpope/vim-vinegar'
Plug 'ap/vim-buftabline'
Plug 'sheerun/vim-polyglot'
Plug 'tpope/vim-commentary'
Plug 'kalbasit/vim-colemak'
call plug#end()
syntax on 
"filetype
filetype on
filetype indent on
filetype plugin on
"set
set nocompatible
set fileformat=unix
set encoding=UTF-8
set number
set rnu
set expandtab
set tabstop=4
set shiftwidth=4
set smarttab 
set smartindent
set noswapfile
set incsearch
set ignorecase
set smartcase
set autochdir
set hidden
set virtualedit=onemore
set timeoutlen=500
set ttimeoutlen=1
set termguicolors
set laststatus=2
set noshowmode
set undofile
set undodir=~/.vim/undodir
set signcolumn=yes
set shortmess+=c
" etc
colorscheme flatwhite
nnoremap <Space> <Nop>
nnoremap <silent> <leader> :WhichKey '<Space>'<CR>
inoremap <silent> <Esc> <Esc>l
autocmd FileType html,css EmmetInstall
"let
let mapleader = "\<Space>"
let g:buftabline_show = 2
let g:buftabline_numbers = 1
let g:user_emmet_leader_key='<Space>'
let g:user_emmet_mode='n'
let g:user_emmet_install_global = 0
let g:lightline = {
            \ 'colorscheme': 'one',
            \ 'background': 'light',
            \ }
let g:loaded_netrw = 1
let g:loaded_netrwPlugin = 1
let g:which_key_map = {}
let g:which_key_map.f = ['Files', 'file buffer']
let g:which_key_map.b = {
            \ 'name' : '+buffer',
            \ 'n' : ['bn', 'next buffer'],
            \ 'p' : ['bp', 'previous buffer'],
            \ 'b' : ['Buffers', 'fuzzy find buffers'],
            \ }
call which_key#register('<Space>', 'g:which_key_map')
" lsp
if executable('pylsp')
    " pip install python-lsp-server
    au User lsp_setup call lsp#register_server({
        \ 'name': 'pylsp',
        \ 'cmd': {server_info->['pylsp']},
        \ 'allowlist': ['python'],
        \ })
endif
if executable('pylsp')
    au User lsp_setup call lsp#register_server({
                \ 'name': 'clangd',
                \ 'cmd': {server_info->['clangd']},
                \ 'allowlist': ['c' 'cpp'],
                \})
endif
function! s:on_lsp_buffer_enabled() abort
    setlocal omnifunc=lsp#complete
    setlocal signcolumn=yes
    if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif
    nmap <buffer> gd <plug>(lsp-definition)
    nmap <buffer> gs <plug>(lsp-document-symbol-search)
    nmap <buffer> gS <plug>(lsp-workspace-symbol-search)
    nmap <buffer> gr <plug>(lsp-references)
    nmap <buffer> gi <plug>(lsp-implementation)
    nmap <buffer> gt <plug>(lsp-type-definition)
    nmap <buffer> <leader>rn <plug>(lsp-rename)
    nmap <buffer> [g <plug>(lsp-previous-diagnostic)
    nmap <buffer> ]g <plug>(lsp-next-diagnostic)
    nmap <buffer> K <plug>(lsp-hover)
    nnoremap <buffer> <expr><c-f> lsp#scroll(+4)
    nnoremap <buffer> <expr><c-d> lsp#scroll(-4)

    let g:lsp_format_sync_timeout = 1000
    autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync')
    
    " refer to doc to add more commands
endfunction

augroup lsp_install
    au!
    " call s:on_lsp_buffer_enabled only for languages that has the server registered.
    autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
augroup END