dotfiles

Cross platform dotfiles for linux, mac and windows

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 
156 
157 
158 
159 
160 
161 
162 
163 
164 
165 
166 
167 
168 
169 
170 
171 
172 
173 
174 
175 
176 
177 
178 
179 
180 
181 
182 
183 
184 
185 
186 
187 
188 
189 
190 
191 
192 
193 
194 
195 
196 
197 
198 
199 
200 
201 
202 
203 
204 
205 
206 
207 
208 
209 
210 
211 
212 
213 
214 
215 
216 
217 
218 
219 
220 
221 
222 
223 
224 
225 
226 
" Handle missing XDG_s gracefully
if !exists("$XDG_HOME")
    let $XDG_HOME = has("win32") ? expand("$USERPROFILE") : expand("$HOME")
endif
if !exists("$XDG_DATA_HOME") | let $XDG_DATA_HOME=expand("$XDG_HOME/.local/share") | endif
if !exists("$XDG_CACHE_HOME") | let $XDG_CACHE_HOME=expand("$XDG_HOME/.cache") | endif

if !exists("$VIM") | let $VIM=expand("$XDG_DATA_HOME/vim") | endif

if has("&viminfofile") | set viminfofile=$XDG_CACHE_HOME/vim/viminfo | endif

set rtp+=$XDG_DATA_HOME/vim

set background=dark
colorscheme hyperred

filetype plugin indent on
syntax on

set packpath^=$XDG_DATA_HOME/vim

source $XDG_DATA_HOME/vim/keybindings.vim

let g:birck_default_chan="irc.libera.chat"

" General
set ai
set exrc
set hidden
set mouse=
set nocompatible
set noexpandtab
set nofixendofline
set shortmess=Iat

" Turn backup off
"set nobackup
"set nowb
"set noswapfile

if v:version >= 901
	set cursorline
	set cursorlineopt=number
	set display=lastline
	set smoothscroll
endif

" Search
set hlsearch
set incsearch
set nowrapscan

set tabstop=4
set shiftwidth=4
set expandtab

" Disable status
set laststatus=1

set nolazyredraw
set ttyfast
set nospell

" Netrw customization
let g:netrw_banner = 0
let g:netrw_liststyle = 3
let g:netrw_fastbrowse= 2
let g:netrw_dirhistmax = 0
let g:netrw_preview = 1
let g:netrw_winsize = 30

set updatetime=100


au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif

let g:loaded_vimballPlugin = 1
let g:loaded_vimball = 1
let g:loaded_getscriptPlugin = 1

let maplocalleader=" "
set complete-=i
set foldmethod=marker             
set foldmarker={,}
set foldlevel=20
set foldopen-=search


" Debug
let g:termdebug_config = {'sign': '>>', 'winbar': 0, 'wide':163}

function! FZYFiles() abort
	let l:tempname = tempname()
	" fzf | awk '{ print $1":1:0" }' > file
	execute 'silent !git ls-files --recurse-submodules | fzf > ' . fnameescape(l:tempname)
	let l:tcontents = join(readfile(l:tempname))
	try
		" TODO Add option to add multiple files to argslist
		"execute 'argadd ' . l:tcontents
		 let bufnr = bufadd(l:tcontents)
		call bufload(bufnr)
		"call setbufline(bufnr, 1, ['some', 'text'])
		execute 'edit ' . l:tcontents
		redraw!
	finally
		call delete(l:tempname)
	endtry
endfunction

set synmaxcol=128

let g:netrw_home = $XDG_DATA_HOME . "/vim"
call mkdir($XDG_DATA_HOME . "/vim/spell", 'p')
set viewdir=$XDG_DATA_HOME/vim/view | call mkdir(&viewdir, 'p')

set backupdir=$XDG_CACHE_HOME/vim/backup | call mkdir(&backupdir, 'p')
set directory=$XDG_CACHE_HOME/vim/swap   | call mkdir(&directory, 'p')
set undodir=$XDG_CACHE_HOME/vim/undo     | call mkdir(&undodir,   'p')

function! s:load_plugins(t) abort
	packadd vim-commentary
	packadd vim-surround
	packadd vim-ninja-feet
	packadd vim-fugitive
	packadd vim-unimpaired
	packadd vim-better-whitespace
	packadd vim-dispatch
	packadd ctrlp.vim
    packadd conflict-marker.vim
    packadd mru

    call s:plugin_post_conf()
endfunction


func! s:plugin_post_conf()
    let g:ctrlp_by_filename = 1
    let g:ctrlp_reuse_window = 'netrw\|help\|quickfix'

    let g:ctrlp_prompt_mappings = {
            \ 'PrtSelectMove("j")':   ['<c-n>', '<down>'],
            \'PrtSelectMove("k")':   ['<c-p>', '<up>'], 
            \ 'PrtHistory(-1)':       ['<c-j>'],
            \ 'PrtHistory(1)':        ['<c-k>'],
            \ }

    if executable('ag')
        " Use Ag over Grep
        set grepprg=ag\ --nogroup\ --nocolor

        " Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
        let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
    endif

    packadd termdebug
    let g:termdebug_wide=163

    if !has("win32")
        packadd vim-tmux-navigator
        packadd notmuch-vim
        let g:notmuch_use_fzf = 1
        let g:notmuch_open_command = 'fzf'
        let g:notmuch_fzf_command = 'fzf --reverse'
        let g:notmuch_use_conversation_view = 1
        let sendmail_path = systemlist('sed -n "s/^set sendmail=\(.*\)$/\1/p; $!d" ~/.mailrc')
        if len(sendmail_path) > 0
            "let g:notmuch_sendmail=sendmail_path[]
        endif
    endif

    let g:lsc_server_commands = {'cpp': 'clangd --log=error'}
    let g:lsc_auto_map = {
        \ 'GoToDefinition': '<C-]>',
        \ 'GoToDefinitionSplit': ['<C-W>]', '<C-W><C-]>'],
        \ 'FindReferences': 'gr',
        \ 'FindImplementations': 'gI',
        \ 'FindCodeActions': 'ga',
        \ 'Rename': 'gR',
        \ 'ShowHover': v:true,
        \ 'DocumentSymbol': 'go',
        \ 'WorkspaceSymbol': 'gS',
        \ 'SignatureHelp': 'gm',
        \ 'Completion': 'completefunc',
        \}
    let g:lsc_enable_autocomplete  = v:true
    let g:lsc_enable_diagnostics   = v:true
    let g:lsc_reference_highlights = v:false
    let g:lsc_trace_level          = 'off'
endfunc

aug user_cmds
	au!
	au VimEnter * call timer_start(20, function('s:load_plugins'))
aug END

source $XDG_DATA_HOME/vim/plugin.vim

if has("gui")
	set guioptions=
	set mouse=a
	if has("win32")
		set guifont=FixedSys:h11:cANSI:qDRAFT
	endif
    " TODO Implement fg or reverse <c-z>
    nnoremap <c-z> :term<cr><c-w>o
    inoremap <c-z> :term<cr><c-w>o
    tnoremap <c-z> <c-w>:hide edit #<cr>
endif

if has("win32")
	set shell=cmd
	set shellquote=\" 
	" shellxquote must be a literal space character.
	set shellxquote=  
else
	set shell=sh
endif

let g:table_mode_toggle_map = 'mm'
let g:table_mode_corner='|'

if !exists('g:undotree_WindowLayout')
	let g:undotree_WindowLayout = 4
	let g:undotree_ShortIndicators = 1
endif