home/.vimrc

217 lines
6.2 KiB
VimL
Raw Normal View History

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'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'bluz71/vim-moonfly-colors', { 'as': 'moonfly' }
Plug 'flazz/vim-colorschemes'
Plug 'vim-python/python-syntax'
Plug 'preservim/nerdtree'
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
" * User Interface
" dark background, by default
"set background=dark
" mouse selection
""set selectmode=mouse
" no beeping, please...
""set vb
" always show status line
""set laststatus=2
" display the current mode and partially-typed commands in the status line
""set showmode
""set showcmd
" default or informative status line
"set statusline=%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
""set statusline=%<%f\ %h%w%m%r%y%{exists('g:loaded_fugitive')?fugitive#statusline():''}%=%-16(\ %l,%c%V\ %)%P
" use '[RO]' for '[readonly]' to save space in the message line
""set shortmess+=r
" 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
" Statusline
"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
set laststatus=2
" Reset statusline
set statusline=
" filename, relative to cwd
set statusline+=%f
" separator
set statusline+=\
" modified flag
set statusline+=%#wildmenu#
set statusline+=%m
set statusline+=%*
"Display a warning if file encoding isnt utf-8
set statusline+=%#question#
set statusline+=%{(&fenc!='utf-8'&&&fenc!='')?'['.&fenc.']':''}
set statusline+=%*
"display a warning if fileformat isnt unix
set statusline+=%#directory#
set statusline+=%{&ff!='unix'?'['.&ff.']':''}
set statusline+=%*
"display a warning if files contains tab chars
set statusline+=%#warningmsg#
set statusline+=%{StatuslineTabWarning()}
set statusline+=%*
" read-only
set statusline+=%r
set statusline+=%*
" right-align
set statusline+=%=
" filetype
set statusline+=[%{strlen(&ft)?&ft:'none'}]
" separator
set statusline+=\
" current char
set statusline+=[%b],[0x%02B]
" separator
set statusline+=\
" column,
set statusline+=(C:%2c),
" current line / lines in file
set statusline+=[%l/%L]
" always show status line
set laststatus=2
" return '[tabs]' if tab chars in file, or empty string
function! StatuslineTabWarning()
if !exists("b:statusline_tab_warning")
let tabs = search('^\t', 'nw') != 0
if tabs
let b:statusline_tab_warning = '[tabs]'
else
let b:statusline_tab_warning = ''
endif
endif
return b:statusline_tab_warning
endfunction
"recalculate the tab warning flag when idle and after writing
autocmd cursorhold,bufwritepost * unlet! b:statusline_tab_warning
2025-08-10 00:53:14 +02:00
2015-06-27 23:08:27 +02:00
2015-06-28 00:14:12 +02:00
" Load NERDTree plugin only if opening vim without a file
2015-06-27 23:08:27 +02:00
"autocmd VimEnter * NERDTree
"autocmd StdinReadPre * let s:std_in=1
"autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
2015-06-28 15:56:58 +02:00
" Open NERDTree with Ctrl+n / Toggle
2025-08-10 01:51:53 +02:00
map <C-n> :NERDTreeToggle<CR>
2015-06-28 15:56:58 +02:00
" close vim if the only window left open is a NERDTree
2025-08-10 00:34:35 +02:00
"autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
2015-06-28 15:56:58 +02:00
2025-08-10 01:57:01 +02:00
nmap <F8> :TagbarToggle<CR>
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
set paste
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 01:51:53 +02:00
""highlight LineNr ctermfg=220 guifg=#ffd700
2015-06-28 00:14:12 +02:00
" Highlight current line and disable highlighting in insert mode
set cursorline
2025-08-10 01:51:53 +02:00
""hi CursorLine cterm=NONE ctermbg=17 ctermfg=white guibg=#00005f guifg=white
2015-06-28 00:14:12 +02:00
"hi CursorColumn cterm=NONE ctermbg=17 ctermfg=white guibg=#00005f guifg=white
2025-08-10 01:51:53 +02:00
""augroup CursorLine
"" au!
"" au VimEnter,WinEnter,BufWinEnter * setlocal cursorline
"" au InsertEnter * setlocal nocursorline
"" au InsertLeave * setlocal cursorline
""augroup END
2015-06-28 00:14:12 +02:00
2015-06-28 17:36:58 +02:00
" 256 bit color support
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
set tabstop=4
set shiftwidth=4
set expandtab
2023-01-19 22:47:59 +01:00
" set number
" filetype indent on
" set autoindent
filetype indent off
set noautoindent
set nocindent
set nosmartindent
2015-06-27 23:22:54 +02:00
2015-06-27 23:41:19 +02:00
" Better command-line completion
set wildmenu
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
" * Load Additional Settings
" OS-specific configuration loading
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
" host-specific configuration loading
let s:hostfile=$HOME . '/.vim/local/host-' . hostname() . '.vim'
if filereadable(s:hostfile)
execute 'source '. s:hostfile
endif