home/.vimrc

224 lines
5.9 KiB
VimL
Raw Normal View History

2025-08-10 04:33:04 +02:00
" Vim configuration from Johannes Findeisen <you@hanez.org>
2025-08-09 19:55:31 +02:00
" Managed plugins
call plug#begin()
2025-08-10 01:51:53 +02:00
" List your plugins here
Plug 'tpope/vim-sensible'
2025-08-10 04:33:04 +02:00
Plug 'tpope/vim-eunuch'
2025-08-10 03:44:48 +02:00
Plug 'tpope/vim-fugitive'
2025-08-10 05:00:04 +02:00
if hostname() == "jupiter"
Plug 'neoclide/coc.nvim', {'branch': 'release'}
endif
2025-08-10 01:51:53 +02:00
Plug 'bluz71/vim-moonfly-colors', { 'as': 'moonfly' }
Plug 'flazz/vim-colorschemes'
Plug 'vim-python/python-syntax'
2025-08-10 03:44:48 +02:00
Plug 'preservim/nerdtree' |
\ Plug 'Xuyuanp/nerdtree-git-plugin'
2025-08-10 01:57:01 +02:00
Plug 'preservim/tagbar'
2025-08-09 19:55:31 +02:00
call plug#end()
2016-06-16 02:11:20 +02:00
2025-08-10 00:53:14 +02:00
" desert feral gentooish grb256 jellygrass kalt last256 matrix
2025-08-10 01:53:22 +02:00
colorscheme molokai
2025-08-10 01:51:53 +02:00
2025-08-10 04:33:04 +02:00
" Dark background, by default (is this needed when setting the colorsheme?).
2025-08-10 03:44:48 +02:00
set background=dark
2025-08-10 04:33:04 +02:00
" Mouse selection
set mouse=
2025-08-10 03:44:48 +02:00
set selectmode=mouse
2025-08-10 04:33:04 +02:00
2025-08-10 03:44:48 +02:00
" No beeping, please...
set vb
2025-08-10 04:33:04 +02:00
2025-08-10 03:44:48 +02:00
" Display the current mode and partially-typed commands in the status line
set showmode
set showcmd
" Highlight current line and disable highlighting in insert mode
set cursorline
2025-08-10 01:51:53 +02:00
" Statusline
2025-08-10 04:52:58 +02:00
set laststatus=2
set showtabline=2
"set statusline=
2025-08-10 01:51:53 +02:00
"set statusline=%f " File name
"set statusline+=%y " File type
"set statusline+=%m " Modified flag [+] if modified
"set statusline+=%r " Read-only flag [RO] if read-only
"set statusline+=%= " Right-align the next section
"set statusline+=%l/%L " Current line / Total lines
"set statusline+=\ [%p%%] " Percentage through the file
"set statusline+=%c " Column number
2025-08-10 03:44:48 +02:00
" ?
set guioptions-=e
2025-08-10 01:51:53 +02:00
" Reset statusline
set statusline=
2025-08-10 04:52:58 +02:00
" Filename, relative to cwd
2025-08-10 01:51:53 +02:00
set statusline+=%f
2025-08-10 04:33:04 +02:00
" Separator
2025-08-10 01:51:53 +02:00
set statusline+=\
2025-08-10 04:52:58 +02:00
" Modified flag
2025-08-10 01:51:53 +02:00
set statusline+=%#wildmenu#
set statusline+=%m
set statusline+=%*
2025-08-10 04:33:04 +02:00
" Display a warning if file encoding isnt utf-8
2025-08-10 01:51:53 +02:00
set statusline+=%#question#
set statusline+=%{(&fenc!='utf-8'&&&fenc!='')?'['.&fenc.']':''}
set statusline+=%*
2025-08-10 04:33:04 +02:00
" Display a warning if fileformat isnt unix
2025-08-10 01:51:53 +02:00
set statusline+=%#directory#
set statusline+=%{&ff!='unix'?'['.&ff.']':''}
set statusline+=%*
2025-08-10 04:33:04 +02:00
" Display a warning if files contains tab chars
2025-08-10 01:51:53 +02:00
set statusline+=%#warningmsg#
set statusline+=%{StatuslineTabWarning()}
set statusline+=%*
2025-08-10 04:33:04 +02:00
" Read-only
2025-08-10 01:51:53 +02:00
set statusline+=%r
set statusline+=%*
2025-08-10 04:33:04 +02:00
" Right-align
2025-08-10 01:51:53 +02:00
set statusline+=%=
2025-08-10 04:33:04 +02:00
" Filetype
2025-08-10 01:51:53 +02:00
set statusline+=[%{strlen(&ft)?&ft:'none'}]
2025-08-10 04:33:04 +02:00
" Separator
2025-08-10 01:51:53 +02:00
set statusline+=\
2025-08-10 04:33:04 +02:00
" Current char
2025-08-10 01:51:53 +02:00
set statusline+=[%b],[0x%02B]
2025-08-10 04:52:58 +02:00
" Separator
2025-08-10 01:51:53 +02:00
set statusline+=\
2025-08-10 04:52:58 +02:00
" Column,
2025-08-10 01:51:53 +02:00
set statusline+=(C:%2c),
2025-08-10 04:52:58 +02:00
" Current line / lines in file
2025-08-10 01:51:53 +02:00
set statusline+=[%l/%L]
2025-08-10 04:52:58 +02:00
" Always show status line
2025-08-10 01:51:53 +02:00
set laststatus=2
2025-08-10 04:52:58 +02:00
" Return '[tabs]' if tab chars in file, or empty string
2025-08-10 01:51:53 +02:00
function! StatuslineTabWarning()
2025-08-10 04:52:58 +02:00
if !exists("b:statusline_tab_warning")
let tabs = search('^\t', 'nw') != 0
2025-08-10 01:51:53 +02:00
2025-08-10 04:52:58 +02:00
if tabs
let b:statusline_tab_warning = '[tabs]'
else
let b:statusline_tab_warning = ''
2025-08-10 01:51:53 +02:00
endif
2025-08-10 04:52:58 +02:00
endif
return b:statusline_tab_warning
2025-08-10 01:51:53 +02:00
endfunction
2025-08-10 03:44:48 +02:00
" Recalculate the tab warning flag when idle and after writing
2025-08-10 01:51:53 +02:00
autocmd cursorhold,bufwritepost * unlet! b:statusline_tab_warning
2025-08-10 00:53:14 +02:00
2025-08-10 03:44:48 +02:00
" Map Ctrl+n to :NERDTreeToggle
2025-08-10 01:51:53 +02:00
map <C-n> :NERDTreeToggle<CR>
2015-06-28 15:56:58 +02:00
2025-08-10 03:44:48 +02:00
" Map F8 to :TagbarToggle
map <F8> :TagbarToggle<CR>
2025-08-10 01:57:01 +02:00
2015-06-27 23:08:27 +02:00
" Remember position in file
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
2015-06-28 17:36:58 +02:00
" Set the clipboard so all vim instances share the same copy/paste buffer
set clipboard=unnamed
2025-08-10 01:51:53 +02:00
" Enable paste mode
2025-08-10 03:44:48 +02:00
"set paste
2025-08-10 01:51:53 +02:00
2015-06-27 23:08:27 +02:00
" Enable syntax highlighting
2015-06-13 02:39:32 +02:00
syntax on
2015-06-27 23:08:27 +02:00
2015-06-28 00:14:12 +02:00
" Show line numbers
2017-04-09 19:21:52 +02:00
"set number
2015-06-28 00:14:12 +02:00
" Set line number color
" Get colors here:
" http://vim.wikia.com/wiki/Xterm256_color_names_for_console_Vim
2025-08-10 03:44:48 +02:00
"highlight LineNr ctermfg=220 guifg=#ffd700
2025-08-10 01:51:53 +02:00
""set t_Co=256
2015-06-28 17:36:58 +02:00
2015-06-27 23:41:19 +02:00
" Set 'nocompatible' to ward off unexpected things that your distro might
" have made, as well as sanely reset options when re-sourcing .vimrc
set nocompatible
2025-08-10 01:51:53 +02:00
" Ensure utf-8 encoding
set encoding=utf-8
2015-06-27 23:08:27 +02:00
" Code indentation
2022-11-01 00:14:39 +01:00
syntax enable
2015-06-27 23:08:27 +02:00
filetype plugin indent on
2025-08-10 04:33:04 +02:00
set tabstop=2
set shiftwidth=2
set softtabstop=2
2015-06-27 23:08:27 +02:00
set expandtab
2025-08-10 04:33:04 +02:00
set autoindent
2025-08-10 04:33:04 +02:00
"filetype indent off
"set noautoindent
"set nocindent
"set nosmartindent
" Show line number
"set number
2015-06-27 23:22:54 +02:00
2015-06-27 23:41:19 +02:00
" Better command-line completion
set wildmenu
2025-08-10 03:44:48 +02:00
" have command-line completion <Tab> (for filenames, help topics, option names)
" first list the available options and complete the longest common part, then
" have further <Tab>s cycle through the possibilities
set wildmode=list:longest,full
2015-06-27 23:41:19 +02:00
2015-06-27 23:22:54 +02:00
" Highlight searches (use <C-L> to temporarily turn off highlighting; see the
" mapping of <C-L> below)
set hlsearch
" Use case insensitive search, except when using capital letters
set ignorecase
set smartcase
2015-06-27 23:41:19 +02:00
" Stop certain movements from always going to the first character of a line.
" While this behaviour deviates from that of Vi, it does what most users
" coming from other editors would expect.
set nostartofline
2015-06-27 23:22:54 +02:00
" Display the cursor position on the last line of the screen or in the status
" line of a window
set ruler
2015-06-27 23:41:19 +02:00
" Instead of failing a command because of unsaved changes, instead raise a
" dialogue asking if you wish to save changed files.
set confirm
2016-06-16 02:11:20 +02:00
2025-08-10 01:51:53 +02:00
" Allow hidden buffers
set hidden
2025-08-10 03:44:48 +02:00
" Automatically enable paste mode when pasting.
" https://stackoverflow.com/questions/2514445/turning-off-auto-indent-when-pasting-text-into-vim/38258720#38258720
" https://coderwall.com/p/if9mda/automatically-set-paste-mode-in-vim-when-pasting-in-insert-mode
let &t_SI .= "\<Esc>[?2004h"
let &t_EI .= "\<Esc>[?2004l"
inoremap <special> <expr> <Esc>[200~ XTermPasteBegin()
function! XTermPasteBegin()
set pastetoggle=<Esc>[201~
set paste
return ""
endfunction
2025-08-10 04:33:04 +02:00
" OS-specific configuration
2025-08-10 01:51:53 +02:00
let s:os=substitute(system('uname -s'), '\n', '', 'g')
let s:osfile=$HOME . '/.vim/local/os-' . s:os . '.vim'
if filereadable(s:osfile)
execute 'source '. s:osfile
endif
2025-08-10 04:33:04 +02:00
" host-specific configuration
2025-08-10 01:51:53 +02:00
let s:hostfile=$HOME . '/.vim/local/host-' . hostname() . '.vim'
if filereadable(s:hostfile)
execute 'source '. s:hostfile
endif