aboutsummaryrefslogtreecommitdiff
path: root/.vimrc
blob: b56e82c0ba6186d92fdc44ae0e9364ad3ba86337 (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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
syntax enable
filetype plugin indent on
set grepprg=grep\ -nH\ $*

set number
set relativenumber
set scrolloff=10
set nocursorline

set conceallevel=2
set laststatus=2

set shiftwidth=2
set tabstop=2
set softtabstop=2
set expandtab

set mouse=

set noswapfile
set nobackup

set magic
set showmatch
set nocompatible

set wildmenu
set wildmode=list:longest,full
set completeopt=longest,menuone,preview
set tags=$MYVIMDIR/system.tags,tags
set omnifunc=syntaxcomplete#Complete

set splitright
set splitbelow
set cmdheight=1
set whichwrap+=<,>,[,]
set ignorecase
set smartcase
set hlsearch
set incsearch
set shortmess-=S
set smartindent
set autoindent

set encoding=utf8
try
  lang en_us
catch
endtry

set background=dark
if has('termguicolors')
  set termguicolors
endif

try
  let g:disable_bg = 1
  let g:disable_float_bg = 1
  colorscheme rosepine
catch /^Vim\%((\a\+)\)\=:E185/
  colorscheme slate
endtry

let b:branch_name = ''
function BranchName()
  let branch = system("git branch --show-current 2> /dev/null | tr -d '\n'")
  if branch != ''
    let b:branch_name=' ' .. branch
  else
    let b:branch_name=''
  endif
  return b:branch_name
endfunction

let g:word_count=wordcount().words
function WordCount()
    if has_key(wordcount(),'visual_words')
        let g:word_count=wordcount().visual_words."/".wordcount().words
    else
        let g:word_count=wordcount().cursor_words."/".wordcount().words
    endif
    return g:word_count
endfunction

set statusline=
set statusline=\ %<\ %f\ %{BranchName()}\ %m\ %=\ [%{&filetype}]\ %l:%c\ 

if has('unnamedplus')
  set clipboard=unnamedplus
else
  set clipboard=unnamed
endif

let mapleader = ' '
let g:mapleader = ' '

map <C-a>v :vert term<cr>
map <C-a>- :term<cr>
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
tnoremap <Esc> <C-\><C-n>
tmap <C-j> <C-\><C-n><C-W>j
tmap <C-k> <C-\><C-n><C-W>k
tmap <C-h> <C-\><C-n><C-W>h
tmap <C-l> <C-\><C-n><C-W>l

map n nzz
map N Nzz

nnoremap <cr> :nohl<cr>
nnoremap <leader>e :Ex<cr>
nnoremap F =ap
nnoremap <leader>rc :e $MYVIMRC<cr>
nnoremap <leader><leader> :!chmod 755 %<cr>

inoremap <C-o> <C-x><C-o>
nnoremap <leader>gd <C-]>
nnoremap <leader>x :bw<cr>
nnoremap <leader>n :bn<cr>
nnoremap <leader>p :bp<cr>

nnoremap <Esc>J :m .+1<cr>==
nnoremap <Esc>K :m .-2<cr>==
vnoremap J :m '>+1<cr>gv=gv
vnoremap K :m '<-2<cr>gv=gv

nnoremap <Esc>a <C-a>
nnoremap <Esc>x <C-x>
vnoremap > >gv
vnoremap < <gv

augroup VimRC
  au!
  au VimEnter * if expand("%") == "" | e . | endif
  au BufWritePost .vimrc source $MYVIMRC
  au FileType make setlocal noexpandtab
  au FileType markdown,mail {
    setlocal spell spelllang=en_us
    setlocal statusline+=\ w:%{WordCount()}
    nnoremap <C-n> ]s
    nnoremap <C-p> [s
  }
  au FileType cs {
    setlocal makeprg=dotnet\ run
    setlocal errorformat=\ %#%f(%l\\\,%c):\ error\ CS%n:\ %m
  }
augroup END