init repository

This commit is contained in:
Sergei Akhmatdinov 2019-11-05 14:11:48 -05:00
commit 3c58690f3c
46 changed files with 6052 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
vim/

13
README.md Normal file
View File

@ -0,0 +1,13 @@
# sakhmatd's dotfiles
This is my personal collection of dotfiles.
Use `GNU stow` to install individual dotfiles as modules.
For example, if you cloned this repo to `~.dotfiles` and you wished
to install my vim config without the modules, use:
```
cd ~/.dotfiles
stow vim
```

2
mpv/.config/mpv/mpv.conf Normal file
View File

@ -0,0 +1,2 @@
ytdl-format="bestvideo[height<=?1080][vcodec!=vp9]+bestaudio/best"

View File

@ -0,0 +1,157 @@
" Vim color file
" Converted from Textmate theme Blackboard Mine using Coloration v0.3.3 (http://github.com/sickill/coloration)
set background=dark
highlight clear
if exists("syntax_on")
syntax reset
endif
let g:colors_name = "blackboard"
hi Normal ctermfg=231 ctermbg=233 cterm=NONE guifg=#f8f8f8 guibg=#0c1021 gui=NONE
hi NonText ctermfg=239 ctermbg=233 cterm=NONE guifg=#494c59 guibg=#0c1021 gui=NONE
hi Cursor ctermfg=233 ctermbg=145 cterm=NONE guifg=#0c1021 guibg=#aaabb1 gui=NONE
hi LineNr ctermfg=102 ctermbg=233 cterm=NONE guifg=#82848d guibg=#0c1021 gui=NONE
hi SignColumn ctermfg=102 ctermbg=233 cterm=NONE guifg=#82848d guibg=#0c1021 gui=NONE
hi VertSplit ctermfg=236 ctermbg=236 cterm=NONE guifg=#242737 guibg=#242737 gui=NONE
hi StatusLine ctermfg=231 ctermbg=240 cterm=bold guifg=#f8f8f8 guibg=#50535f gui=bold
hi StatusLineNC ctermfg=231 ctermbg=240 cterm=NONE guifg=#f8f8f8 guibg=#50535f gui=NONE
hi Folded ctermfg=145 ctermbg=233 cterm=NONE guifg=#aeaeae guibg=#0c1021 gui=NONE
hi Title ctermfg=231 ctermbg=NONE cterm=bold guifg=#f8f8f8 guibg=NONE gui=bold
hi Visual ctermfg=NONE ctermbg=24 cterm=NONE guifg=NONE guibg=#253b76 gui=NONE
hi SpecialKey ctermfg=239 ctermbg=236 cterm=NONE guifg=#494c59 guibg=#242737 gui=NONE
hi ErrorMsg ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE
hi WarningMsg ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE
if version >= 700
hi CursorLine ctermfg=NONE ctermbg=236 cterm=NONE guifg=NONE guibg=#242737 gui=NONE
hi CursorColumn ctermfg=NONE ctermbg=236 cterm=NONE guifg=NONE guibg=#242737 gui=NONE
hi Pmenu ctermfg=202 ctermbg=NONE cterm=NONE guifg=#ff6400 guibg=NONE gui=NONE
hi PmenuSel ctermfg=NONE ctermbg=24 cterm=NONE guifg=NONE guibg=#253b76 gui=NONE
hi Search ctermfg=16 ctermbg=222 cterm=underline guifg=#000000 guibg=#fcdf86 gui=NONE
endif
hi ColorColumn ctermfg=NONE ctermbg=236 cterm=NONE guifg=NONE guibg=#242737 gui=NONE
hi IncSearch ctermfg=233 ctermbg=77 cterm=NONE guifg=#0c1021 guibg=#61ce3c gui=NONE
hi Directory ctermfg=110 ctermbg=NONE cterm=NONE guifg=#8da6ce guibg=NONE gui=NONE
" Syntax highlighting
hi Comment ctermfg=145 ctermbg=NONE cterm=NONE guifg=#aeaeae guibg=NONE gui=NONE
hi String ctermfg=77 ctermbg=NONE cterm=NONE guifg=#61ce3c guibg=NONE gui=NONE
hi Number ctermfg=191 ctermbg=NONE cterm=NONE guifg=#d8fa3c guibg=NONE gui=NONE
hi Keyword ctermfg=220 ctermbg=NONE cterm=NONE guifg=#fbde2d guibg=NONE gui=NONE
hi PreProc ctermfg=220 ctermbg=NONE cterm=NONE guifg=#fbde2d guibg=NONE gui=NONE
hi Conditional ctermfg=214 ctermbg=NONE cterm=NONE guifg=#fdbe2d guibg=NONE gui=NONE
hi Todo ctermfg=145 ctermbg=NONE cterm=inverse,bold guifg=#aeaeae guibg=NONE gui=inverse,bold
hi Constant ctermfg=114 ctermbg=NONE cterm=NONE guifg=#99cc99 guibg=NONE gui=NONE
hi Identifier ctermfg=220 ctermbg=NONE cterm=NONE guifg=#fbde2d guibg=NONE gui=NONE
hi Function ctermfg=202 ctermbg=NONE cterm=NONE guifg=#ff6400 guibg=NONE gui=NONE
hi Type ctermfg=220 ctermbg=NONE cterm=NONE guifg=#fbde2d guibg=NONE gui=NONE
hi Statement ctermfg=220 ctermbg=NONE cterm=NONE guifg=#fbde2d guibg=NONE gui=NONE
hi Special ctermfg=110 ctermbg=NONE cterm=NONE guifg=#8da6ce guibg=NONE gui=NONE
hi Operator ctermfg=220 ctermbg=NONE cterm=NONE guifg=#fbde2d guibg=NONE gui=NONE
hi Boolean ctermfg=191 ctermbg=NONE cterm=NONE guifg=#d8fa3c guibg=NONE gui=NONE
hi Character ctermfg=191 ctermbg=NONE cterm=NONE guifg=#d8fa3c guibg=NONE gui=NONE
hi Define ctermfg=220 ctermbg=NONE cterm=NONE guifg=#fbde2d guibg=NONE gui=NONE
hi DiffAdd ctermfg=231 ctermbg=64 cterm=bold guifg=#f8f8f8 guibg=#417e0b gui=bold
hi DiffDelete ctermfg=88 ctermbg=NONE cterm=NONE guifg=#860307 guibg=NONE gui=NONE
hi DiffChange ctermfg=231 ctermbg=236 cterm=NONE guifg=#f8f8f8 guibg=#162d54 gui=NONE
hi DiffText ctermfg=231 ctermbg=24 cterm=bold guifg=#f8f8f8 guibg=#204a87 gui=bold
hi Float ctermfg=191 ctermbg=NONE cterm=NONE guifg=#d8fa3c guibg=NONE gui=NONE
hi Label ctermfg=77 ctermbg=NONE cterm=NONE guifg=#61ce3c guibg=NONE gui=NONE
hi StorageClass ctermfg=220 ctermbg=NONE cterm=NONE guifg=#fbde2d guibg=NONE gui=NONE
hi Tag ctermfg=202 ctermbg=NONE cterm=NONE guifg=#ff6400 guibg=NONE gui=NONE
hi Underlined ctermfg=NONE ctermbg=NONE cterm=underline guifg=NONE guibg=NONE gui=underline
hi link Character Constant
hi link Boolean Constant
hi link Float Number
hi link Repeat Statement
hi link Label Statement
hi link Exception Statement
hi link Include PreProc
hi link Define PreProc
hi link Macro PreProc
hi link PreCondit PreProc
hi link StorageClass Type
hi link Structure Type
hi link Typedef Type
hi link Tag Special
hi link SpecialChar Special
hi link SpecialComment Special
hi link Debug Special
" Ruby
hi rubyClass ctermfg=220 ctermbg=NONE cterm=NONE guifg=#fbde2d guibg=NONE gui=NONE
hi rubyFunction ctermfg=202 ctermbg=NONE cterm=NONE guifg=#ff6400 guibg=NONE gui=NONE
hi rubyInterpolationDelimiter ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE
hi rubySymbol ctermfg=191 ctermbg=NONE cterm=NONE guifg=#d8fa3c guibg=NONE gui=NONE
hi rubyConstant ctermfg=110 ctermbg=NONE cterm=NONE guifg=#8da6ce guibg=NONE gui=NONE
hi rubyStringDelimiter ctermfg=77 ctermbg=NONE cterm=NONE guifg=#61ce3c guibg=NONE gui=NONE
hi rubyBlockParameter ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE
hi rubyInstanceVariable ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE
hi rubyInclude ctermfg=220 ctermbg=NONE cterm=NONE guifg=#fbde2d guibg=NONE gui=NONE
hi rubyGlobalVariable ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE
hi rubyRegexp ctermfg=77 ctermbg=NONE cterm=NONE guifg=#61ce3c guibg=NONE gui=NONE
hi rubyRegexpDelimiter ctermfg=77 ctermbg=NONE cterm=NONE guifg=#61ce3c guibg=NONE gui=NONE
hi rubyEscape ctermfg=191 ctermbg=NONE cterm=NONE guifg=#d8fa3c guibg=NONE gui=NONE
hi rubyControl ctermfg=220 ctermbg=NONE cterm=NONE guifg=#fbde2d guibg=NONE gui=NONE
hi rubyClassVariable ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE
hi rubyOperator ctermfg=220 ctermbg=NONE cterm=NONE guifg=#fbde2d guibg=NONE gui=NONE
hi rubyException ctermfg=220 ctermbg=NONE cterm=NONE guifg=#fbde2d guibg=NONE gui=NONE
hi rubyPseudoVariable ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE
hi rubyRailsUserClass ctermfg=110 ctermbg=NONE cterm=NONE guifg=#8da6ce guibg=NONE gui=NONE
hi rubyRailsARAssociationMethod ctermfg=110 ctermbg=NONE cterm=NONE guifg=#8da6ce guibg=NONE gui=NONE
hi rubyRailsARMethod ctermfg=110 ctermbg=NONE cterm=NONE guifg=#8da6ce guibg=NONE gui=NONE
hi rubyRailsRenderMethod ctermfg=110 ctermbg=NONE cterm=NONE guifg=#8da6ce guibg=NONE gui=NONE
hi rubyRailsMethod ctermfg=110 ctermbg=NONE cterm=NONE guifg=#8da6ce guibg=NONE gui=NONE
hi erubyDelimiter ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE
hi erubyComment ctermfg=145 ctermbg=NONE cterm=NONE guifg=#aeaeae guibg=NONE gui=NONE
hi erubyRailsMethod ctermfg=110 ctermbg=NONE cterm=NONE guifg=#8da6ce guibg=NONE gui=NONE
" html
hi htmlTag ctermfg=103 ctermbg=NONE cterm=NONE guifg=#7f90aa guibg=NONE gui=NONE
hi htmlEndTag ctermfg=103 ctermbg=NONE cterm=NONE guifg=#7f90aa guibg=NONE gui=NONE
hi htmlTagName ctermfg=103 ctermbg=NONE cterm=NONE guifg=#7f90aa guibg=NONE gui=NONE
hi htmlArg ctermfg=103 ctermbg=NONE cterm=NONE guifg=#7f90aa guibg=NONE gui=NONE
hi htmlSpecialChar ctermfg=191 ctermbg=NONE cterm=NONE guifg=#d8fa3c guibg=NONE gui=NONE
" javascript
hi javaScriptFunction ctermfg=220 ctermbg=NONE cterm=NONE guifg=#fbde2d guibg=NONE gui=NONE
hi javaScriptRailsFunction ctermfg=110 ctermbg=NONE cterm=NONE guifg=#8da6ce guibg=NONE gui=NONE
hi javaScriptBraces ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE
" yaml
hi yamlKey ctermfg=202 ctermbg=NONE cterm=NONE guifg=#ff6400 guibg=NONE gui=NONE
hi yamlAnchor ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE
hi yamlAlias ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE
hi yamlDocumentHeader ctermfg=77 ctermbg=NONE cterm=NONE guifg=#61ce3c guibg=NONE gui=NONE
" css
hi cssURL ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE
hi cssFunctionName ctermfg=110 ctermbg=NONE cterm=NONE guifg=#8da6ce guibg=NONE gui=NONE
hi cssColor ctermfg=191 ctermbg=NONE cterm=NONE guifg=#d8fa3c guibg=NONE gui=NONE
hi cssPseudoClassId ctermfg=202 ctermbg=NONE cterm=NONE guifg=#ff6400 guibg=NONE gui=NONE
hi cssClassName ctermfg=202 ctermbg=NONE cterm=NONE guifg=#ff6400 guibg=NONE gui=NONE
hi cssValueLength ctermfg=191 ctermbg=NONE cterm=NONE guifg=#d8fa3c guibg=NONE gui=NONE
hi cssCommonAttr ctermfg=110 ctermbg=NONE cterm=NONE guifg=#8da6ce guibg=NONE gui=NONE
hi cssBraces ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE
" NERDTree
hi NERDTreeDirSlash guifg=#82848d
hi NERDTreeCWD guifg=#aeaeae

View File

@ -0,0 +1,3 @@
GuiFont Input:h20
color blackboard

View File

@ -0,0 +1,3 @@
set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath = &runtimepath
source ~/.vimrc

106
vim/.vimrc Normal file
View File

@ -0,0 +1,106 @@
" Turn off vi compatibility, makes vim a lot better
set nocompatible
" Detect file types
filetype indent plugin on
" Enable syntax highlighting
syntax on
" Colorscheme
colorscheme blackboard
" Font
set guifont=Input\ 18
" Other good font options:
" set guifont=Inconsolata\ LGC\ 18
" set guifont=Fira\ Code\ 18
" Remove toolbar
set guioptions-=T
" Don't force file saving on buffer changes
set hidden
" Better command-line completion
set wildmenu
" Show partial commands in the last line of the screen
set showcmd
" Highlight searches
set hlsearch
" Use case insensitive search, except when using capital letters
set ignorecase
set smartcase
" Allow backspacing over autoindent, line breaks and start of insert action
set backspace=indent,eol,start
" When opening a new line and no filetype-specific indenting is enabled, keep
" the same indent as the line you're currently on. Useful for READMEs, etc.
set autoindent
" Stop certain movements from always going to the first character of a line.
set nostartofline
" Display the cursor position on the last line of the screen or in the status
" line of a window
set ruler
" Always display the status line, even if only one window is displayed
set laststatus=2
" Instead of failing a command because of unsaved changes, instead raise a
" dialogue asking if you wish to save changed files.
set confirm
" Use visual bell instead of beeping when doing something wrong
set visualbell
" And reset the terminal code for the visual bell. If visualbell is set, and
" this line is also included, vim will neither flash nor beep. If visualbell
" is unset, this does nothing.
set t_vb=
" Enable use of the mouse for all modes
set mouse=a
" Set the command window height to 2 lines, to avoid many cases of having to
" "press <Enter> to continue"
" set cmdheight=2
" Display line numbers on the left
set number
" Quickly time out on keycodes, but never time out on mappings
set notimeout ttimeout ttimeoutlen=200
" Use <F11> to toggle between 'paste' and 'nopaste'
set pastetoggle=<F11>
" Indentation options
set shiftwidth=8
set tabstop=8
" 80 column rule
highlight OverLength ctermbg=darkred ctermfg=white guibg=#592929
match OverLength /\%81v.\+/
" Paste normally
set clipboard=unnamedplus
vmap <C-c> "+yi
vmap <C-x> "+c
vmap <C-v> c<ESC>"+p
imap <C-v> <C-r><C-o>+
function! SourceIfExists(file)
if filereadable(expand(a:file))
exe 'source' a:file
endif
endfunction
" Plugins
call SourceIfExists("~/.vim/plugins.vim")

10
vimplugins/.vim/README.md Normal file
View File

@ -0,0 +1,10 @@
## Installation
After cloning the repo and using stow to install vimplugins, make sure to
run `:PlugInstall` after launching vim.
## Plugins
Simply browse through the `plugged` directory or look at `plugins.vim`
to get the list of the installed plugins.

File diff suppressed because it is too large Load Diff

@ -0,0 +1 @@
Subproject commit 39f06b873a8449af8ff6a3eee716d3da14d63a76

View File

@ -0,0 +1,3 @@
*.pyc
*.vba
tags

View File

@ -0,0 +1,14 @@
SHELL=/bin/bash
all: dist
dist:
@vim -c 'r! git ls-files autoload bin doc plugin' \
-c '$$,$$d _' \
-c '%MkVimball! clang_complete.vba .' -c 'q!'
install: dist
@vim clang_complete.vba -c 'so %' -c 'q'
clean:
@rm -f clang_complete.vba

View File

@ -0,0 +1,15 @@
This plugin uses clang for accurately completing C and C++ code.
To build and install in one step, type:
$ make install
To build and install in two steps, type:
$ make
$ vim clang_complete.vba -c 'so %' -c 'q'
Alternatively, you can also put the files in ~/.vim/
You need Vim 7.3 or higher, compiled with python support and ideally, with
the conceal feature.
See doc/clang_complete.txt for help and license.

View File

@ -0,0 +1,96 @@
" clang_complete clang_complete's snippet generator
" Author: Xavier Deguillard, Philippe Vaucher
function! snippets#clang_complete#init()
noremap <expr> <silent> <buffer> <tab> UpdateSnips()
snoremap <expr> <silent> <buffer> <tab> UpdateSnips()
syntax match Conceal /<#/ conceal
syntax match Conceal /#>/ conceal
endfunction
" fullname = strcat(char *dest, const char *src)
" args_pos = [ [8, 17], [20, 34] ]
function! snippets#clang_complete#add_snippet(fullname, args_pos)
let l:res = ''
let l:prev_idx = 0
for elt in a:args_pos
let l:res .= a:fullname[l:prev_idx : elt[0] - 1] . '<#' . a:fullname[elt[0] : elt[1] - 1] . '#>'
let l:prev_idx = elt[1]
endfor
let l:res .= a:fullname[l:prev_idx : ]
return l:res
endfunction
function! snippets#clang_complete#trigger()
call s:BeginSnips()
endfunction
function! snippets#clang_complete#reset()
endfunction
" ---------------- Helpers ----------------
function! UpdateSnips()
let l:line = getline('.')
let l:pattern = '<#[^#]*#>'
if match(l:line, l:pattern) == -1
return "\<c-i>"
endif
let l:commands = ""
if mode() != 'n'
let l:commands .= "\<esc>"
endif
let l:commands .= ":call MoveToCCSnippetBegin()\<CR>"
let l:commands .= "m'"
let l:commands .= ":call MoveToCCSnippetEnd()\<CR>"
if &selection == "exclusive"
let l:commands .= "ll"
else
let l:commands .= "l"
endif
let l:commands .= "v`'o\<C-G>"
return l:commands
endfunction
function! MoveToCCSnippetBegin()
let l:pattern = '<#'
let l:line = getline('.')
let l:startpos = col('.') + 1
let l:ind = match(l:line, l:pattern, l:startpos)
if l:ind == -1
let l:ind = match(l:line, l:pattern, 0)
endif
call cursor(line('.'), l:ind + 1)
endfunction
function! MoveToCCSnippetEnd()
let l:line = getline('.')
let l:pattern = '#>'
let l:startpos = col('.') + 2
call cursor(line('.'), match(l:line, l:pattern, l:startpos) + 1)
endfunction
function! s:BeginSnips()
if pumvisible() != 0
return
endif
" Do we need to launch UpdateSnippets()?
let l:line = getline('.')
let l:pattern = '<#[^#]*#>'
if match(l:line, l:pattern) == -1
return
endif
call feedkeys("\<esc>^\<tab>")
endfunction
" vim: set ts=2 sts=2 sw=2 expandtab :

View File

@ -0,0 +1,24 @@
" Prepare the snippet engine
function! snippets#dummy#init()
echo 'Initializing stuffs'
endfunction
" Add a snippet to be triggered
" fullname: contain an unmangled name. ex: strcat(char *dest, const char *src)
" args_pos: contain the position of the argument in fullname. ex [ [8, 17], [20, 34] ]
" Returns: text to be inserted for when trigger() is called
function! snippets#dummy#add_snippet(fullname, args_pos)
echo 'Creating snippet for "' . a:fullname
return a:fullname
endfunction
" Trigger the snippet
" Note: usually as simple as triggering the tab key
function! snippets#dummy#trigger()
echo 'Triggering snippet'
endfunction
" Remove all snippets
function! snippets#dummy#reset()
echo 'Resetting all snippets'
endfunction

View File

@ -0,0 +1,50 @@
" clang_complete snipmate's snippet generator
" Author: Philippe Vaucher
function! snippets#snipmate#init()
call snippets#snipmate#reset()
endfunction
" fullname = strcat(char *dest, const char *src)
" args_pos = [ [8, 17], [20, 34] ]
function! snippets#snipmate#add_snippet(fullname, args_pos)
" If we are already in a snipmate snippet, well not much we can do until snipmate supports nested snippets
if exists('g:snipPos')
return a:fullname
endif
let l:snip = ''
let l:prev_idx = 0
let l:snip_idx = 1
for elt in a:args_pos
let l:snip .= a:fullname[l:prev_idx : elt[0] - 1] . '${' . l:snip_idx . ':' . a:fullname[elt[0] : elt[1] - 1] . '}'
let l:snip_idx += 1
let l:prev_idx = elt[1]
endfor
let l:snip .= a:fullname[l:prev_idx : ] . '${' . l:snip_idx . '}'
let l:snippet_id = substitute(a:fullname, ' ', '_', 'g')
call MakeSnip(&filetype, l:snippet_id, l:snip)
return l:snippet_id
endfunction
function! snippets#snipmate#trigger()
" If we are already in a snipmate snippet, well not much we can do until snipmate supports nested snippets
if exists('g:snipPos')
return
endif
" Trigger snipmate
call feedkeys("\<Tab>", 't')
endfunction
function! snippets#snipmate#reset()
" Quick & Easy way to prevent snippets to be added twice
" Ideally we should modify snipmate to be smarter about this
call ReloadSnippets(&filetype)
endfunction
" vim: set ts=2 sts=2 sw=2 expandtab :

View File

@ -0,0 +1,37 @@
" clang_complete ultisnips's snippet generator
" Author: Philippe Vaucher
function! snippets#ultisnips#init()
call snippets#ultisnips#reset()
endfunction
" fullname = strcat(char *dest, const char *src)
" args_pos = [ [8, 17], [20, 34] ]
function! snippets#ultisnips#add_snippet(fullname, args_pos)
let l:snip = ''
let l:prev_idx = 0
let l:snip_idx = 1
for elt in a:args_pos
let l:snip .= a:fullname[l:prev_idx : elt[0] - 1] . '${' . l:snip_idx . ':' . a:fullname[elt[0] : elt[1] - 1] . '}'
let l:snip_idx += 1
let l:prev_idx = elt[1]
endfor
let l:snip .= a:fullname[l:prev_idx : ] . '${' . l:snip_idx . '}'
let l:snippet_id = substitute(a:fullname, ' ', '_', 'g')
call UltiSnips_AddSnippet(l:snippet_id, l:snip, a:fullname, 'i', &filetype)
return l:snippet_id
endfunction
function! snippets#ultisnips#trigger()
call UltiSnips_ExpandSnippet()
endfunction
function! snippets#ultisnips#reset()
python UltiSnips_Manager.reset()
endfunction
" vim: set ts=2 sts=2 sw=2 expandtab :

View File

@ -0,0 +1,84 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import os
import sys
CONFIG_NAME = ".clang_complete"
def readConfiguration():
try:
f = open(CONFIG_NAME, "r")
except IOError:
return []
result = []
for line in f.readlines():
strippedLine = line.strip()
if len(strippedLine) > 0:
result += [strippedLine]
f.close()
return result
def writeConfiguration(lines):
f = open(CONFIG_NAME, "w")
f.writelines(lines)
f.close()
def parseArguments(arguments):
nextIsInclude = False
nextIsDefine = False
nextIsIncludeFile = False
includes = []
defines = []
include_file = []
for arg in arguments:
if nextIsInclude:
includes += [arg]
nextIsInclude = False
elif nextIsDefine:
defines += [arg]
nextIsDefine = False
elif nextIsIncludeFile:
include_file += [arg]
nextIsIncludeFile = False
elif arg == "-I":
nextIsInclude = True
elif arg == "-D":
nextIsDefine = True
elif arg[:2] == "-I":
includes += [arg[2:]]
elif arg[:2] == "-D":
defines += [arg[2:]]
elif arg == "-include":
nextIsIncludeFile = True
result = map(lambda x: "-I" + x, includes)
result += map(lambda x: "-D" + x, defines)
result += map(lambda x: "-include " + x, include_file)
return result
def mergeLists(base, new):
result = list(base)
for newLine in new:
try:
result.index(newLine)
except ValueError:
result += [newLine]
return result
configuration = readConfiguration()
args = parseArguments(sys.argv)
result = mergeLists(configuration, args)
writeConfiguration(map(lambda x: x + "\n", result))
status = os.system(" ".join(sys.argv[1:]))
if not os.WIFEXITED(status):
sys.exit(1)
sys.exit(os.WEXITSTATUS(status))
# vim: set ts=2 sts=2 sw=2 expandtab :

View File

@ -0,0 +1,257 @@
*clang_complete.txt* For Vim version 7.3. Last change: 2011 Jun 04
clang_complete plugin documentation
clang_complete plugin *clang_complete*
1. Description |clang_complete-description|
2. Completion kinds |clang_complete-compl_kinds|
3. Configuration |clang_complete-configuration|
4. Options |clang_complete-options|
5. Known issues |clang_complete-issues|
6. PCH |clang_complete-pch|
7. cc_args.py script |clang_complete-cc_args|
8. To do |clang_complete-todo|
9. License |clang_complete-license|
Author: Xavier Deguillard <deguilx@gmail.com> *clang_complete-author*
==============================================================================
1. Description *clang_complete-description*
This plugin use clang for accurately completing C and C++ code.
Note: This plugin is incompatible with omnicppcomplete due to the
unconditionnaly set mapping done by omnicppcomplete. So don't forget to
suppress it before using this plugin.
==============================================================================
2. Completion kinds *clang_complete-compl_kinds*
Because libclang provides a lot of information about completion, there are
some additional kinds of completion along with standard ones (see >
:help complete-items
for details):
'+' - constructor
'~' - destructor
'e' - enumerator constant
'a' - parameter ('a' from "argument") of a function, method or template
'u' - unknown or buildin type (int, float, ...)
'n' - namespace or its alias
'p' - template ('p' from "pattern")
==============================================================================
3. Configuration *clang_complete-configuration*
Each project can have a .clang_complete at his root, containing the compiler
options. This is useful if you're using some non-standard include paths. For
simplicity, please don't put relative and absolute include path on the same
line. It is not currently correctly handled.
==============================================================================
4. Options *clang_complete-options*
*clang_complete-auto_select*
*g:clang_auto_select*
If equal to 0, nothing is selected.
If equal to 1, automatically select the first entry in the popup menu, but
without inserting it into the code.
If equal to 2, automatically select the first entry in the popup menu, and
insert it into the code.
Default: 0
*clang_complete-complete_auto*
*g:clang_complete_auto*
If equal to 1, automatically complete after ->, ., ::
Default: 1
*clang_complete-copen*
*g:clang_complete_copen*
If equal to 1, open quickfix window on error.
Default: 0
*clang_complete-hl_errors*
*g:clang_hl_errors*
If equal to 1, it will highlight the warnings and errors the same way clang
does it.
Default: 1
*clang_complete-periodic_quickfix*
*g:clang_periodic_quickfix*
If equal to 1, it will periodically update the quickfix window.
Default: 0
Note: You could use the g:ClangUpdateQuickFix() to do the same with a mapping.
*clang_complete-snippets*
*g:clang_snippets*
If equal to 1, it will do some snippets magic after a ( or a , inside function
call. Not currently fully working.
Default: 0
*clang_complete-snippets_engine*
*g:clang_snippets_engine*
The snippets engine (clang_complete, snipmate, ultisnips... see the snippets
subdirectory).
Default: "clang_complete"
*clang_complete-conceal_snippets*
*g:clang_conceal_snippets*
If equal to 1, vim will use vim 7.3 conceal feature to hide <# and #> which
delimit a snippets.
Default: 1 (0 if conceal not available)
Note: See concealcursor and conceallevel for conceal configuration.
*clang_complete-exec*
*g:clang_exec*
Name or path of clang executable.
Note: Use this if clang has a non-standard name, or isn't in the path.
Default: "clang"
*clang_complete-user_options*
*g:clang_user_options*
Option added at the end of clang command. Useful if you want to filter the
result, or do other stuffs. To ignore the error code returned by clang, set
|g:clang_exec| to `"clang` and |g:clang_user_options| to `2>/dev/null || exit
0"` if you're on *nix, or `2>NUL || exit 0"` if you are on windows.
Default: ""
*clang_complete-auto_user_options*
*g:clang_auto_user_options*
Set sources for user options passed to clang. Available sources are:
- path - use &path content as list of include directories (relative paths are
ignored)
- .clang_complete - use information from .clang_complete file Multiple options
are separated by comma.
Default: "path, .clang_complete"
*clang_complete-use_library*
*g:clang_use_library*
Instead of calling the clang/clang++ tool use libclang directly. This gives
access to many more clang features. Furthermore it automatically caches all
includes in memory. Updates after changes in the same file will therefore be a
lot faster.
Default: 0
*clang_complete-library_path*
*g:clang_library_path*
If libclang.[dll/so/dylib] is not in your library search path, set this to the
absolute path where libclang is available.
Default: ""
*clang_complete-sort_algo*
*g:clang_sort_algo*
How results are sorted (alpha, priority). Currently only works with libclang.
Default: "priority"
*clang_complete-complete_macros*
*g:clang_complete_macros*
If clang should complete preprocessor macros and constants.
Default: 0
*clang_complete-complete_patterns*
*g:clang_complete_patterns*
If clang should complete code patterns, i.e loop constructs etc.
Defaut: 0
==============================================================================
5. Known issues *clang_complete-issues*
If you find that completion is slow, please read the |clang_complete-pch|
section below.
If you get following error message while trying to complete anything: >
E121: Undefined variable: b:should_overload
it means that your version of Vim is too old (this is an old bug and it has
been fixed with one of patches for Vim 7.2) and you need to update it.
If clang is not able to compile your file, it cannot complete anything. Since
clang is not supporting every C++0x features, this is normal if it can do any
completion on C++0x file.
There is no difference in clang's output between private methods/members and
public ones. Which means that I cannot filter private methods on the
completion list.
==============================================================================
6. PCH *clang_complete-pch*
In case you can not or you do not want to install libclang, a precompiled
header file is another way to accelerate compilation, and so, to accelerate
the completion. It is however more complicated to install and is still slower
than the use of libclang.
Here is how to create the <vector> pch, on linux (OSX users may use
-fnext-runtime instead of -fgnu-runtime): >
clang -x c++-header /path/to/c++/vector -fno-exceptions -fgnu-runtime \
-o vector.pch
You just have to insert it into your .clang_complete: >
echo '-include-pch /path/to/vector.pch -fgnu-runtime' >> .clang_complete
<
One of the major problem is that you cannot include more that one pch, the
solution is to put the system headers or non changing headers into another
header and then compile it to pch: >
echo '#include <iostream>\n#include <vector>' > pchheader.h
clang -x c++-header ./pchheader.h -fno-exceptions -fnu-runtime \
-o ./pchheader.pch
And then add it to the .clang_complete file.
==============================================================================
7. cc_args.py script *clang_complete-cc_args*
This script, installed at ~/.vim/bin/cc_args.py, could be used to generate or
update the .clang_complete file. It works similar to gccsence's gccrec and
simply stores -I and -D arguments passed to the compiler in the
.clang_complete file. Just add the cc_args.py script as the first argument of
the compile command. You should do that every time compile options have
changed.
Example (we need -B flag to force compiling even if project is up to date): >
make CC='~/.vim/bin/cc_args.py gcc' CXX='~/.vim/bin/cc_args.py g++' -B
After running this command, .clang_complete will be created or updated with
new options. If you don't want to update an existing configuration file,
delete it before running make.
==============================================================================
8. To do *clang_complete-todo*
- Write some unit tests
- clang vs libclang accuracy for complex completions
- clang vs libclang timing
- Explore "jump to declaration/definition" with libclang FGJ
- Think about supertab (<C-X><C-U> with supertab and clang_auto_select)
- Parse fix-its and do something useful with it
==============================================================================
9. License *clang_complete-license*
Copyright (c) 2010, 2011, Xavier Deguillard
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Xavier Deguillard nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL XAVIER DEGUILLARD BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Note: This license does not cover the files that come from the LLVM project,
namely, cindex.py and __init__.py, which are covered by the LLVM license.
vim:tw=78:ts=8:ft=help:norl:

View File

@ -0,0 +1,24 @@
#===- __init__.py - Clang Python Bindings --------------------*- python -*--===#
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
#===------------------------------------------------------------------------===#
r"""
Clang Library Bindings
======================
This package provides access to the Clang compiler and libraries.
The available modules are:
cindex
Bindings for the Clang indexing library.
"""
__all__ = ['cindex']

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,668 @@
"
" File: clang_complete.vim
" Author: Xavier Deguillard <deguilx@gmail.com>
"
" Description: Use of clang to complete in C/C++.
"
" Help: Use :help clang_complete
"
au FileType c,cpp,objc,objcpp call <SID>ClangCompleteInit()
let b:clang_parameters = ''
let b:clang_user_options = ''
let b:my_changedtick = 0
" Store plugin path, as this is available only when sourcing the file,
" not during a function call.
let s:plugin_path = escape(expand('<sfile>:p:h'), '\')
function! s:ClangCompleteInit()
if !exists('g:clang_auto_select')
let g:clang_auto_select = 0
endif
if !exists('g:clang_complete_auto')
let g:clang_complete_auto = 1
endif
if !exists('g:clang_complete_copen')
let g:clang_complete_copen = 0
endif
if !exists('g:clang_hl_errors')
let g:clang_hl_errors = 1
endif
if !exists('g:clang_periodic_quickfix')
let g:clang_periodic_quickfix = 0
endif
if !exists('g:clang_snippets')
let g:clang_snippets = 0
endif
if !exists('g:clang_snippets_engine')
let g:clang_snippets_engine = 'clang_complete'
endif
if !exists('g:clang_exec')
let g:clang_exec = 'clang'
endif
if !exists('g:clang_user_options')
let g:clang_user_options = ''
endif
" Only use libclang if the user clearly show intent to do so for now
if !exists('g:clang_use_library')
let g:clang_use_library = (has('python') && exists('g:clang_library_path'))
endif
if !exists('g:clang_complete_macros')
let g:clang_complete_macros = 0
endif
if !exists('g:clang_complete_patterns')
let g:clang_complete_patterns = 0
endif
if !exists('g:clang_debug')
let g:clang_debug = 0
endif
if !exists('g:clang_sort_algo')
let g:clang_sort_algo = 'priority'
endif
if !exists('g:clang_auto_user_options')
let g:clang_auto_user_options = 'path, .clang_complete'
endif
call LoadUserOptions()
inoremap <expr> <buffer> <C-X><C-U> <SID>LaunchCompletion()
inoremap <expr> <buffer> . <SID>CompleteDot()
inoremap <expr> <buffer> > <SID>CompleteArrow()
inoremap <expr> <buffer> : <SID>CompleteColon()
inoremap <expr> <buffer> <CR> <SID>HandlePossibleSelectionEnter()
if g:clang_snippets == 1
call g:ClangSetSnippetEngine(g:clang_snippets_engine)
endif
" Force menuone. Without it, when there's only one completion result,
" it can be confusing (not completing and no popup)
if g:clang_auto_select != 2
set completeopt-=menu
set completeopt+=menuone
endif
" Disable every autocmd that could have been set.
augroup ClangComplete
autocmd!
augroup end
let b:should_overload = 0
let b:my_changedtick = b:changedtick
let b:clang_parameters = '-x c'
if &filetype == 'objc'
let b:clang_parameters = '-x objective-c'
endif
if &filetype == 'cpp' || &filetype == 'objcpp'
let b:clang_parameters .= '++'
endif
if expand('%:e') =~ 'h*'
let b:clang_parameters .= '-header'
endif
let g:clang_complete_lib_flags = 0
if g:clang_complete_macros == 1
let b:clang_parameters .= ' -code-completion-macros'
let g:clang_complete_lib_flags = 1
endif
if g:clang_complete_patterns == 1
let b:clang_parameters .= ' -code-completion-patterns'
let g:clang_complete_lib_flags += 2
endif
setlocal completefunc=ClangComplete
setlocal omnifunc=ClangComplete
if g:clang_periodic_quickfix == 1
augroup ClangComplete
au CursorHold,CursorHoldI <buffer> call <SID>DoPeriodicQuickFix()
augroup end
endif
" Load the python bindings of libclang
if g:clang_use_library == 1
if has('python')
exe s:initClangCompletePython()
else
echoe 'clang_complete: No python support available.'
echoe 'Cannot use clang library, using executable'
echoe 'Compile vim with python support to use libclang'
let g:clang_use_library = 0
return
endif
endif
endfunction
function! LoadUserOptions()
let b:clang_user_options = ''
let l:option_sources = split(g:clang_auto_user_options, ',')
let l:remove_spaces_cmd = 'substitute(v:val, "\\s*\\(.*\\)\\s*", "\\1", "")'
let l:option_sources = map(l:option_sources, l:remove_spaces_cmd)
for l:source in l:option_sources
if l:source == 'path'
call s:parsePathOption()
elseif l:source == '.clang_complete'
call s:parseConfig()
endif
endfor
endfunction
function! s:parseConfig()
let l:local_conf = findfile('.clang_complete', getcwd() . ',.;')
if l:local_conf == '' || !filereadable(l:local_conf)
return
endif
let l:opts = readfile(l:local_conf)
for l:opt in l:opts
" Better handling of absolute path
" I don't know if those pattern will work on windows
" platform
if matchstr(l:opt, '\C-I\s*/') != ''
let l:opt = substitute(l:opt, '\C-I\s*\(/\%(\w\|\\\s\)*\)',
\ '-I' . '\1', 'g')
else
let l:opt = substitute(l:opt, '\C-I\s*\(\%(\w\|\\\s\)*\)',
\ '-I' . l:local_conf[:-16] . '\1', 'g')
endif
let b:clang_user_options .= ' ' . l:opt
endfor
endfunction
function! s:parsePathOption()
let l:dirs = split(&path, ',')
for l:dir in l:dirs
if len(l:dir) == 0 || !isdirectory(l:dir)
continue
endif
" Add only absolute paths
if matchstr(l:dir, '\s*/') != ''
let l:opt = '-I' . l:dir
let b:clang_user_options .= ' ' . l:opt
endif
endfor
endfunction
function! s:initClangCompletePython()
" Only parse the python library once
if !exists('s:libclang_loaded')
python import sys
if exists('g:clang_library_path')
" Load the library from the given library path.
exe 'python sys.argv = ["' . escape(g:clang_library_path, '\') . '"]'
else
" By setting argv[0] to '' force the python bindings to load the library
" from the normal system search path.
python sys.argv[0] = ''
endif
exe 'python sys.path = ["' . s:plugin_path . '"] + sys.path'
exe 'pyfile ' . s:plugin_path . '/libclang.py'
python initClangComplete(vim.eval('g:clang_complete_lib_flags'))
let s:libclang_loaded = 1
endif
python WarmupCache()
endfunction
function! s:GetKind(proto)
if a:proto == ''
return 't'
endif
let l:ret = match(a:proto, '^\[#')
let l:params = match(a:proto, '(')
if l:ret == -1 && l:params == -1
return 't'
endif
if l:ret != -1 && l:params == -1
return 'v'
endif
if l:params != -1
return 'f'
endif
return 'm'
endfunction
function! s:CallClangBinaryForDiagnostics(tempfile)
let l:escaped_tempfile = shellescape(a:tempfile)
let l:buf = getline(1, '$')
try
call writefile(l:buf, a:tempfile)
catch /^Vim\%((\a\+)\)\=:E482/
return
endtry
let l:command = g:clang_exec . ' -cc1 -fsyntax-only'
\ . ' -fno-caret-diagnostics -fdiagnostics-print-source-range-info'
\ . ' ' . l:escaped_tempfile
\ . ' ' . b:clang_parameters . ' ' . b:clang_user_options . ' ' . g:clang_user_options
let l:clang_output = split(system(l:command), "\n")
call delete(a:tempfile)
return l:clang_output
endfunction
function! s:CallClangForDiagnostics(tempfile)
if g:clang_use_library == 1
python updateCurrentDiagnostics()
else
return s:CallClangBinaryForDiagnostics(a:tempfile)
endif
endfunction
function! s:DoPeriodicQuickFix()
" Don't do any superfluous reparsing.
if b:my_changedtick == b:changedtick
return
endif
let b:my_changedtick = b:changedtick
" Create tempfile name for clang/clang++ executable mode
let b:my_changedtick = b:changedtick
let l:tempfile = expand('%:p:h') . '/' . localtime() . expand('%:t')
let l:clang_output = s:CallClangForDiagnostics(l:tempfile)
call s:ClangQuickFix(l:clang_output, l:tempfile)
endfunction
function! s:ClangQuickFix(clang_output, tempfname)
" Clear the bad spell, the user may have corrected them.
syntax clear SpellBad
syntax clear SpellLocal
if g:clang_use_library == 0
let l:list = s:ClangUpdateQuickFix(a:clang_output, a:tempfname)
else
python vim.command('let l:list = ' + str(getCurrentQuickFixList()))
python highlightCurrentDiagnostics()
endif
if g:clang_complete_copen == 1
" We should get back to the original buffer
let l:bufnr = bufnr('%')
" Workaround:
" http://vim.1045645.n5.nabble.com/setqflist-inconsistency-td1211423.html
if l:list == []
cclose
else
copen
endif
let l:winbufnr = bufwinnr(l:bufnr)
exe l:winbufnr . 'wincmd w'
endif
call setqflist(l:list)
silent doautocmd QuickFixCmdPost make
endfunction
function! s:ClangUpdateQuickFix(clang_output, tempfname)
let l:list = []
for l:line in a:clang_output
let l:erridx = match(l:line, '\%(error\|warning\|note\): ')
if l:erridx == -1
" Error are always at the beginning.
if l:line[:11] == 'COMPLETION: ' || l:line[:9] == 'OVERLOAD: '
break
endif
continue
endif
let l:pattern = '^\(.*\):\(\d*\):\(\d*\):\(\%({\d\+:\d\+-\d\+:\d\+}\)*\)'
let l:tmp = matchstr(l:line, l:pattern)
let l:fname = substitute(l:tmp, l:pattern, '\1', '')
if l:fname == a:tempfname
let l:fname = '%'
endif
let l:bufnr = bufnr(l:fname, 1)
let l:lnum = substitute(l:tmp, l:pattern, '\2', '')
let l:col = substitute(l:tmp, l:pattern, '\3', '')
let l:errors = substitute(l:tmp, l:pattern, '\4', '')
if l:line[l:erridx] == 'e'
let l:text = l:line[l:erridx + 7:]
let l:type = 'E'
let l:hlgroup = ' SpellBad '
elseif l:line[l:erridx] == 'w'
let l:text = l:line[l:erridx + 9:]
let l:type = 'W'
let l:hlgroup = ' SpellLocal '
else
let l:text = l:line[l:erridx + 6:]
let l:type = 'I'
let l:hlgroup = ' '
endif
let l:item = {
\ 'bufnr': l:bufnr,
\ 'lnum': l:lnum,
\ 'col': l:col,
\ 'text': l:text,
\ 'type': l:type }
let l:list = add(l:list, l:item)
if g:clang_hl_errors == 0 || l:fname != '%' || l:type == 'I'
continue
endif
" Highlighting the ^
let l:pat = '/\%' . l:lnum . 'l' . '\%' . l:col . 'c./'
exe 'syntax match' . l:hlgroup . l:pat
if l:errors == ''
continue
endif
let l:ranges = split(l:errors, '}')
for l:range in l:ranges
" Doing precise error and warning handling.
" The highlight will be the same as clang's carets.
let l:pattern = '{\%(\d\+\):\(\d\+\)-\%(\d\+\):\(\d\+\)'
let l:tmp = matchstr(l:range, l:pattern)
let l:startcol = substitute(l:tmp, l:pattern, '\1', '')
let l:endcol = substitute(l:tmp, l:pattern, '\2', '')
" Highlighting the ~~~~
let l:pat = '/\%' . l:lnum . 'l'
\ . '\%' . l:startcol . 'c'
\ . '.*'
\ . '\%' . l:endcol . 'c/'
exe 'syntax match' . l:hlgroup . l:pat
endfor
endfor
return l:list
endfunction
function! s:DemangleProto(prototype)
let l:proto = substitute(a:prototype, '\[#[^#]*#\]', '', 'g')
let l:proto = substitute(l:proto, '{#.*#}', '', 'g')
return l:proto
endfunction
let b:col = 0
function! s:ClangCompleteBinary(base)
let l:buf = getline(1, '$')
let l:tempfile = expand('%:p:h') . '/' . localtime() . expand('%:t')
try
call writefile(l:buf, l:tempfile)
catch /^Vim\%((\a\+)\)\=:E482/
return {}
endtry
let l:escaped_tempfile = shellescape(l:tempfile)
let l:command = g:clang_exec . ' -cc1 -fsyntax-only'
\ . ' -fno-caret-diagnostics -fdiagnostics-print-source-range-info'
\ . ' -code-completion-at=' . l:escaped_tempfile . ':'
\ . line('.') . ':' . b:col . ' ' . l:escaped_tempfile
\ . ' ' . b:clang_parameters . ' ' . b:clang_user_options . ' ' . g:clang_user_options
let l:clang_output = split(system(l:command), "\n")
call delete(l:tempfile)
call s:ClangQuickFix(l:clang_output, l:tempfile)
if v:shell_error
return []
endif
if l:clang_output == []
return []
endif
let l:filter_str = "v:val =~ '^COMPLETION: " . a:base . "\\|^OVERLOAD: '"
call filter(l:clang_output, l:filter_str)
let l:res = []
for l:line in l:clang_output
if l:line[:11] == 'COMPLETION: ' && b:should_overload != 1
let l:value = l:line[12:]
let l:colonidx = stridx(l:value, ' : ')
if l:colonidx == -1
let l:wabbr = s:DemangleProto(l:value)
let l:word = l:value
let l:proto = l:value
else
let l:word = l:value[:l:colonidx - 1]
" WTF is that?
if l:word =~ '(Hidden)'
let l:word = l:word[:-10]
endif
let l:wabbr = l:word
let l:proto = l:value[l:colonidx + 3:]
endif
let l:kind = s:GetKind(l:proto)
if l:kind == 't' && b:clang_complete_type == 0
continue
endif
let l:word = l:wabbr
let l:proto = s:DemangleProto(l:proto)
elseif l:line[:9] == 'OVERLOAD: ' && b:should_overload == 1
let l:value = l:line[10:]
if match(l:value, '<#') == -1
continue
endif
let l:word = substitute(l:value, '.*<#', '<#', 'g')
let l:word = substitute(l:word, '#>.*', '#>', 'g')
let l:wabbr = substitute(l:word, '<#\([^#]*\)#>', '\1', 'g')
let l:proto = l:value
let l:proto = s:DemangleProto(l:value)
let l:kind = ''
else
continue
endif
let l:args_pos = []
if g:clang_snippets == 1
let l:startidx = match(l:proto, '<#')
while l:startidx != -1
let l:proto = substitute(l:proto, '<#', '', '')
let l:endidx = match(l:proto, '#>')
let l:proto = substitute(l:proto, '#>', '', '')
let l:args_pos += [[ l:startidx, l:endidx ]]
let l:startidx = match(l:proto, '<#')
endwhile
endif
let l:item = {
\ 'word': l:word,
\ 'abbr': l:wabbr,
\ 'menu': l:proto,
\ 'info': l:proto,
\ 'dup': 0,
\ 'kind': l:kind,
\ 'args_pos': l:args_pos }
call add(l:res, l:item)
endfor
return l:res
endfunction
function! ClangComplete(findstart, base)
if a:findstart
let l:line = getline('.')
let l:start = col('.') - 1
let b:clang_complete_type = 1
let l:wsstart = l:start
if l:line[l:wsstart - 1] =~ '\s'
while l:wsstart > 0 && l:line[l:wsstart - 1] =~ '\s'
let l:wsstart -= 1
endwhile
endif
if l:line[l:wsstart - 1] =~ '[(,]'
let b:should_overload = 1
let b:col = l:wsstart + 1
return l:wsstart
endif
let b:should_overload = 0
while l:start > 0 && l:line[l:start - 1] =~ '\i'
let l:start -= 1
endwhile
if l:line[l:start - 2:] =~ '->' || l:line[l:start - 1] == '.'
let b:clang_complete_type = 0
endif
let b:col = l:start + 1
return l:start
else
if g:clang_debug == 1
let l:time_start = reltime()
endif
if g:clang_snippets == 1
call b:ResetSnip()
endif
if g:clang_use_library == 1
python vim.command('let l:res = ' + str(getCurrentCompletions(vim.eval('a:base'))))
else
let l:res = s:ClangCompleteBinary(a:base)
endif
for item in l:res
if g:clang_snippets == 1
let item['word'] = b:AddSnip(item['info'], item['args_pos'])
else
let item['word'] = item['abbr']
endif
endfor
if g:clang_snippets == 1
inoremap <expr> <buffer> <C-Y> <SID>HandlePossibleSelectionCtrlY()
augroup ClangComplete
au CursorMovedI <buffer> call <SID>TriggerSnippet()
augroup end
let b:snippet_chosen = 0
endif
if g:clang_debug == 1
echom 'clang_complete: completion time (' . (g:clang_use_library == 1 ? 'library' : 'binary') . ') '. split(reltimestr(reltime(l:time_start)))[0]
endif
return l:res
endif
endfunction
function! s:HandlePossibleSelectionEnter()
if pumvisible()
let b:snippet_chosen = 1
return "\<C-Y>"
end
return "\<CR>"
endfunction
function! s:HandlePossibleSelectionCtrlY()
if pumvisible()
let b:snippet_chosen = 1
end
return "\<C-Y>"
endfunction
function! s:TriggerSnippet()
" Dont bother doing anything until we're sure the user exited the menu
if !b:snippet_chosen
return
endif
" Stop monitoring as we'll trigger a snippet
silent! iunmap <buffer> <C-Y>
augroup ClangComplete
au! CursorMovedI <buffer>
augroup end
" Trigger the snippet
call b:TriggerSnip()
endfunction
function! s:ShouldComplete()
if (getline('.') =~ '#\s*\(include\|import\)')
return 0
else
if col('.') == 1
return 1
endif
for l:id in synstack(line('.'), col('.') - 1)
if match(synIDattr(l:id, 'name'), '\CComment\|String\|Number')
\ != -1
return 0
endif
endfor
return 1
endif
endfunction
function! s:LaunchCompletion()
let l:result = ""
if s:ShouldComplete()
let l:result = "\<C-X>\<C-U>"
if g:clang_auto_select != 2
let l:result .= "\<C-P>"
endif
if g:clang_auto_select == 1
let l:result .= "\<C-R>=(pumvisible() ? \"\\<Down>\" : '')\<CR>"
endif
endif
return l:result
endfunction
function! s:CompleteDot()
if g:clang_complete_auto == 1
return '.' . s:LaunchCompletion()
endif
return '.'
endfunction
function! s:CompleteArrow()
if g:clang_complete_auto != 1 || getline('.')[col('.') - 2] != '-'
return '>'
endif
return '>' . s:LaunchCompletion()
endfunction
function! s:CompleteColon()
if g:clang_complete_auto != 1 || getline('.')[col('.') - 2] != ':'
return ':'
endif
return ':' . s:LaunchCompletion()
endfunction
" May be used in a mapping to update the quickfix window.
function! g:ClangUpdateQuickFix()
call s:DoPeriodicQuickFix()
return ''
endfunction
function! g:ClangSetSnippetEngine(engine_name)
try
call eval('snippets#' . a:engine_name . '#init()')
let b:AddSnip = function('snippets#' . a:engine_name . '#add_snippet')
let b:ResetSnip = function('snippets#' . a:engine_name . '#reset')
let b:TriggerSnip = function('snippets#' . a:engine_name . '#trigger')
catch /^Vim\%((\a\+)\)\=:E117/
echoe 'Snippets engine ' . a:engine_name . ' not found.'
let g:clang_snippets = 0
endtry
endfunction
" vim: set ts=2 sts=2 sw=2 expandtab :

View File

@ -0,0 +1,381 @@
from clang.cindex import *
import vim
import time
import re
import threading
def initClangComplete(clang_complete_flags):
global index
index = Index.create()
global translationUnits
translationUnits = dict()
global complete_flags
complete_flags = int(clang_complete_flags)
# Get a tuple (fileName, fileContent) for the file opened in the current
# vim buffer. The fileContent contains the unsafed buffer content.
def getCurrentFile():
file = "\n".join(vim.eval("getline(1, '$')"))
return (vim.current.buffer.name, file)
def getCurrentTranslationUnit(args, currentFile, fileName, update = False):
if fileName in translationUnits:
tu = translationUnits[fileName]
if update:
if debug:
start = time.time()
tu.reparse([currentFile])
if debug:
elapsed = (time.time() - start)
print "LibClang - Reparsing: " + str(elapsed)
return tu
if debug:
start = time.time()
flags = TranslationUnit.PrecompiledPreamble | TranslationUnit.CXXPrecompiledPreamble # | TranslationUnit.CacheCompletionResults
tu = index.parse(fileName, args, [currentFile], flags)
if debug:
elapsed = (time.time() - start)
print "LibClang - First parse: " + str(elapsed)
if tu == None:
print "Cannot parse this source file. The following arguments " \
+ "are used for clang: " + " ".join(args)
return None
translationUnits[fileName] = tu
# Reparse to initialize the PCH cache even for auto completion
# This should be done by index.parse(), however it is not.
# So we need to reparse ourselves.
if debug:
start = time.time()
tu.reparse([currentFile])
if debug:
elapsed = (time.time() - start)
print "LibClang - First reparse (generate PCH cache): " + str(elapsed)
return tu
def splitOptions(options):
optsList = []
opt = ""
quoted = False
for char in options:
if char == ' ' and not quoted:
if opt != "":
optsList += [opt]
opt = ""
continue
elif char == '"':
quoted = not quoted
opt += char
if opt != "":
optsList += [opt]
return optsList
def getQuickFix(diagnostic):
# Some diagnostics have no file, e.g. "too many errors emitted, stopping now"
if diagnostic.location.file:
filename = diagnostic.location.file.name
else:
filename = ""
if diagnostic.severity == diagnostic.Ignored:
type = 'I'
elif diagnostic.severity == diagnostic.Note:
type = 'I'
elif diagnostic.severity == diagnostic.Warning:
type = 'W'
elif diagnostic.severity == diagnostic.Error:
type = 'E'
elif diagnostic.severity == diagnostic.Fatal:
type = 'E'
else:
return None
return dict({ 'bufnr' : int(vim.eval("bufnr('" + filename + "', 1)")),
'lnum' : diagnostic.location.line,
'col' : diagnostic.location.column,
'text' : diagnostic.spelling,
'type' : type})
def getQuickFixList(tu):
return filter (None, map (getQuickFix, tu.diagnostics))
def highlightRange(range, hlGroup):
pattern = '/\%' + str(range.start.line) + 'l' + '\%' \
+ str(range.start.column) + 'c' + '.*' \
+ '\%' + str(range.end.column) + 'c/'
command = "exe 'syntax match' . ' " + hlGroup + ' ' + pattern + "'"
vim.command(command)
def highlightDiagnostic(diagnostic):
if diagnostic.severity == diagnostic.Warning:
hlGroup = 'SpellLocal'
elif diagnostic.severity == diagnostic.Error:
hlGroup = 'SpellBad'
else:
return
pattern = '/\%' + str(diagnostic.location.line) + 'l\%' \
+ str(diagnostic.location.column) + 'c./'
command = "exe 'syntax match' . ' " + hlGroup + ' ' + pattern + "'"
vim.command(command)
# Use this wired kind of iterator as the python clang libraries
# have a bug in the range iterator that stops us to use:
#
# | for range in diagnostic.ranges
#
for i in range(len(diagnostic.ranges)):
highlightRange(diagnostic.ranges[i], hlGroup)
def highlightDiagnostics(tu):
map (highlightDiagnostic, tu.diagnostics)
def highlightCurrentDiagnostics():
if vim.current.buffer.name in translationUnits:
highlightDiagnostics(translationUnits[vim.current.buffer.name])
def getCurrentQuickFixList():
if vim.current.buffer.name in translationUnits:
return getQuickFixList(translationUnits[vim.current.buffer.name])
return []
def updateCurrentDiagnostics():
global debug
debug = int(vim.eval("g:clang_debug")) == 1
userOptionsGlobal = splitOptions(vim.eval("g:clang_user_options"))
userOptionsLocal = splitOptions(vim.eval("b:clang_user_options"))
args = userOptionsGlobal + userOptionsLocal
getCurrentTranslationUnit(args, getCurrentFile(),
vim.current.buffer.name, update = True)
def getCurrentCompletionResults(line, column, args, currentFile, fileName):
tu = getCurrentTranslationUnit(args, currentFile, fileName)
if debug:
start = time.time()
cr = tu.codeComplete(fileName, line, column, [currentFile],
complete_flags)
if debug:
elapsed = (time.time() - start)
print "LibClang - Code completion time: " + str(elapsed)
return cr
def formatResult(result):
completion = dict()
abbr = getAbbr(result.string)
word = filter(lambda x: not x.isKindInformative() and not x.isKindResultType(), result.string)
args_pos = []
cur_pos = 0
for chunk in word:
chunk_len = len(chunk.spelling)
if chunk.isKindPlaceHolder():
args_pos += [[ cur_pos, cur_pos + chunk_len ]]
cur_pos += chunk_len
word = "".join(map(lambda x: x.spelling, word))
completion['word'] = word
completion['abbr'] = abbr
completion['menu'] = word
completion['info'] = word
completion['args_pos'] = args_pos
completion['dup'] = 0
# Replace the number that represents a specific kind with a better
# textual representation.
completion['kind'] = kinds[result.cursorKind]
return completion
class CompleteThread(threading.Thread):
lock = threading.Lock()
def __init__(self, line, column, currentFile, fileName):
threading.Thread.__init__(self)
self.line = line
self.column = column
self.currentFile = currentFile
self.fileName = fileName
self.result = None
userOptionsGlobal = splitOptions(vim.eval("g:clang_user_options"))
userOptionsLocal = splitOptions(vim.eval("b:clang_user_options"))
self.args = userOptionsGlobal + userOptionsLocal
def run(self):
try:
CompleteThread.lock.acquire()
if self.line == -1:
# Warm up the caches. For this it is sufficient to get the current
# translation unit. No need to retrieve completion results.
# This short pause is necessary to allow vim to initialize itself.
# Otherwise we would get: E293: block was not locked
# The user does not see any delay, as we just pause a background thread.
time.sleep(0.1)
getCurrentTranslationUnit(self.args, self.currentFile, self.fileName)
else:
self.result = getCurrentCompletionResults(self.line, self.column,
self.args, self.currentFile, self.fileName)
except Exception:
pass
CompleteThread.lock.release()
def WarmupCache():
global debug
debug = int(vim.eval("g:clang_debug")) == 1
t = CompleteThread(-1, -1, getCurrentFile(), vim.current.buffer.name)
t.start()
return
def getCurrentCompletions(base):
global debug
debug = int(vim.eval("g:clang_debug")) == 1
priority = vim.eval("g:clang_sort_algo") == 'priority'
line = int(vim.eval("line('.')"))
column = int(vim.eval("b:col"))
t = CompleteThread(line, column, getCurrentFile(), vim.current.buffer.name)
t.start()
while t.isAlive():
t.join(0.01)
cancel = int(vim.eval('complete_check()'))
if cancel != 0:
return []
cr = t.result
if cr is None:
return []
regexp = re.compile("^" + base)
filteredResult = filter(lambda x: regexp.match(getAbbr(x.string)), cr.results)
getPriority = lambda x: x.string.priority
getAbbrevation = lambda x: getAbbr(x.string).lower()
if priority:
key = getPriority
else:
key = getAbbrevation
sortedResult = sorted(filteredResult, None, key)
return map(formatResult, sortedResult)
def getAbbr(strings):
tmplst = filter(lambda x: x.isKindTypedText(), strings)
if len(tmplst) == 0:
return ""
else:
return tmplst[0].spelling
kinds = dict({ \
# Declarations \
1 : 't', # CXCursor_UnexposedDecl (A declaration whose specific kind is not \
# exposed via this interface) \
2 : 't', # CXCursor_StructDecl (A C or C++ struct) \
3 : 't', # CXCursor_UnionDecl (A C or C++ union) \
4 : 't', # CXCursor_ClassDecl (A C++ class) \
5 : 't', # CXCursor_EnumDecl (An enumeration) \
6 : 'm', # CXCursor_FieldDecl (A field (in C) or non-static data member \
# (in C++) in a struct, union, or C++ class) \
7 : 'e', # CXCursor_EnumConstantDecl (An enumerator constant) \
8 : 'f', # CXCursor_FunctionDecl (A function) \
9 : 'v', # CXCursor_VarDecl (A variable) \
10 : 'a', # CXCursor_ParmDecl (A function or method parameter) \
11 : '11', # CXCursor_ObjCInterfaceDecl (An Objective-C @interface) \
12 : '12', # CXCursor_ObjCCategoryDecl (An Objective-C @interface for a \
# category) \
13 : '13', # CXCursor_ObjCProtocolDecl (An Objective-C @protocol declaration) \
14 : '14', # CXCursor_ObjCPropertyDecl (An Objective-C @property declaration) \
15 : '15', # CXCursor_ObjCIvarDecl (An Objective-C instance variable) \
16 : '16', # CXCursor_ObjCInstanceMethodDecl (An Objective-C instance method) \
17 : '17', # CXCursor_ObjCClassMethodDecl (An Objective-C class method) \
18 : '18', # CXCursor_ObjCImplementationDec (An Objective-C @implementation) \
19 : '19', # CXCursor_ObjCCategoryImplDecll (An Objective-C @implementation \
# for a category) \
20 : 't', # CXCursor_TypedefDecl (A typedef) \
21 : 'f', # CXCursor_CXXMethod (A C++ class method) \
22 : 'n', # CXCursor_Namespace (A C++ namespace) \
23 : '23', # CXCursor_LinkageSpec (A linkage specification, e.g. 'extern "C"') \
24 : '+', # CXCursor_Constructor (A C++ constructor) \
25 : '~', # CXCursor_Destructor (A C++ destructor) \
26 : '26', # CXCursor_ConversionFunction (A C++ conversion function) \
27 : 'a', # CXCursor_TemplateTypeParameter (A C++ template type parameter) \
28 : 'a', # CXCursor_NonTypeTemplateParameter (A C++ non-type template \
# parameter) \
29 : 'a', # CXCursor_TemplateTemplateParameter (A C++ template template \
# parameter) \
30 : 'f', # CXCursor_FunctionTemplate (A C++ function template) \
31 : 'p', # CXCursor_ClassTemplate (A C++ class template) \
32 : '32', # CXCursor_ClassTemplatePartialSpecialization (A C++ class template \
# partial specialization) \
33 : 'n', # CXCursor_NamespaceAlias (A C++ namespace alias declaration) \
34 : '34', # CXCursor_UsingDirective (A C++ using directive) \
35 : '35', # CXCursor_UsingDeclaration (A using declaration) \
\
# References \
40 : '40', # CXCursor_ObjCSuperClassRef \
41 : '41', # CXCursor_ObjCProtocolRef \
42 : '42', # CXCursor_ObjCClassRef \
43 : '43', # CXCursor_TypeRef \
44 : '44', # CXCursor_CXXBaseSpecifier \
45 : '45', # CXCursor_TemplateRef (A reference to a class template, function \
# template, template template parameter, or class template partial \
# specialization) \
46 : '46', # CXCursor_NamespaceRef (A reference to a namespace or namespace \
# alias) \
47 : '47', # CXCursor_MemberRef (A reference to a member of a struct, union, \
# or class that occurs in some non-expression context, e.g., a \
# designated initializer) \
48 : '48', # CXCursor_LabelRef (A reference to a labeled statement) \
49 : '49', # CXCursor_OverloadedDeclRef (A reference to a set of overloaded \
# functions or function templates that has not yet been resolved to \
# a specific function or function template) \
\
# Error conditions \
#70 : '70', # CXCursor_FirstInvalid \
70 : '70', # CXCursor_InvalidFile \
71 : '71', # CXCursor_NoDeclFound \
72 : 'u', # CXCursor_NotImplemented \
73 : '73', # CXCursor_InvalidCode \
\
# Expressions \
100 : '100', # CXCursor_UnexposedExpr (An expression whose specific kind is \
# not exposed via this interface) \
101 : '101', # CXCursor_DeclRefExpr (An expression that refers to some value \
# declaration, such as a function, varible, or enumerator) \
102 : '102', # CXCursor_MemberRefExpr (An expression that refers to a member \
# of a struct, union, class, Objective-C class, etc) \
103 : '103', # CXCursor_CallExpr (An expression that calls a function) \
104 : '104', # CXCursor_ObjCMessageExpr (An expression that sends a message \
# to an Objective-C object or class) \
105 : '105', # CXCursor_BlockExpr (An expression that represents a block \
# literal) \
\
# Statements \
200 : '200', # CXCursor_UnexposedStmt (A statement whose specific kind is not \
# exposed via this interface) \
201 : '201', # CXCursor_LabelStmt (A labelled statement in a function) \
\
# Translation unit \
300 : '300', # CXCursor_TranslationUnit (Cursor that represents the \
# translation unit itself) \
\
# Attributes \
400 : '400', # CXCursor_UnexposedAttr (An attribute whose specific kind is \
# not exposed via this interface) \
401 : '401', # CXCursor_IBActionAttr \
402 : '402', # CXCursor_IBOutletAttr \
403 : '403', # CXCursor_IBOutletCollectionAttr \
\
# Preprocessing \
500 : '500', # CXCursor_PreprocessingDirective \
501 : 'd', # CXCursor_MacroDefinition \
502 : '502', # CXCursor_MacroInstantiation \
503 : '503' # CXCursor_InclusionDirective \
})
# vim: set ts=2 sts=2 sw=2 expandtab :

@ -0,0 +1 @@
Subproject commit 9f43dcb5a244faba6aedb6879b75a56c7de4b8ff

@ -0,0 +1 @@
Subproject commit a486aa1d24294c5b14c8b2763a3b5ffdc39d0739

@ -0,0 +1 @@
Subproject commit 70a11ee67f3c4353e48aad69812c34b5c8489f07

@ -0,0 +1 @@
Subproject commit ab11b74be4b0c9fac88d95f0f563d0dc0cb06ed3

@ -0,0 +1 @@
Subproject commit 359a80e3a34aacbd5257713b6a88aa085337166f

@ -0,0 +1 @@
Subproject commit c9ab296e856bed4e694180efb6ffb692cf18ed8f

@ -0,0 +1 @@
Subproject commit 2d639b70e73ecf3f62884a578fe5e5937e6d8a92

@ -0,0 +1 @@
Subproject commit 8fcb1af27772174df5446d49de29052cac47e46f

@ -0,0 +1 @@
Subproject commit 339091ac4dd1f17e225fe7d57b48aff55f99b23a

@ -0,0 +1 @@
Subproject commit 62b68aecec2de531bc3978bfb9c07d3b6759ce0e

@ -0,0 +1 @@
Subproject commit e066a0999e442d9d96f24ad9d203b1bd030ef72e

@ -0,0 +1 @@
Subproject commit 1725c13add66c6981d9406f109dcd64dff5fbf59

@ -0,0 +1 @@
Subproject commit 6532acee7a06b2420160279fdd397b9d8e5f1e8a

@ -0,0 +1 @@
Subproject commit da5a7ac96f517e0fd6f886bc3fbe27156ca1f946

@ -0,0 +1 @@
Subproject commit 2609c9b054b562b6bf46936f3e80a25042c5d572

@ -0,0 +1 @@
Subproject commit fab8621670f71637e9960003af28365129b1dfd0

View File

@ -0,0 +1,32 @@
" vim-plug
call plug#begin('~/.vim/plugged')
Plug 'plasticboy/vim-markdown'
Plug 'godlygeek/tabular'
Plug 'w0rp/ale'
Plug 'airblade/vim-gitgutter'
Plug 'itchyny/lightline.vim'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
Plug 'scrooloose/nerdtree'
Plug 'terryma/vim-multiple-cursors'
Plug 'tpope/vim-eunuch'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary'
Plug 'Shougo/deoplete.nvim'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
call plug#end()
" Toggle NERDTree
map <C-o> :NERDTreeToggle<CR>
" fzf
map ; :Files<CR>
" Deoplete
let g:deoplete#enable_at_startup = 1
" <TAB>: completion.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" Disable markdown folding
let g:vim_markdown_folding_disabled = 1

16
xbindkeys/.xbindkeysrc Normal file
View File

@ -0,0 +1,16 @@
"mixer vol +5"
XF86AudioRaiseVolume
"mixer vol -5"
XF86AudioLowerVolume
"mixer vol mute"
m:0x0 + c:140
"sudo zzz"
XF86Sleep
"setxkbmap us"
Control + 1
"setxkbmap ru"
Control + 2
"rotate-screen.sh"
Mod4 + f
"scrot -s"
Shift + Print

8
xinitrc/.xinitrc Normal file
View File

@ -0,0 +1,8 @@
export QT_QPA_PLATFORMTHEME=qt5ct
# Wallpaper
xsetroot -solid "#008080" &
xbindkeys &
sdwmbar &
exec dwm

View File

@ -0,0 +1,43 @@
# Sakhmatd ZSH Theme
# Based on gnzh theme, which is based on the bira theme
setopt prompt_subst
() {
local PR_USER PR_USER_OP PR_PROMPT PR_HOST
PR_USER='%F{green}%n%f'
PR_USER_OP='%F{green}%#%f'
PR_PROMPT='%f➤ %f'
# Check if we are on SSH or not
if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then
PR_HOST='%F{red}%M%f' # SSH
else
PR_HOST='%F{green}%M%f' # no SSH
fi
local return_code="%(?..%F{red}%? ↵%f)"
local user_host="${PR_USER}%F{cyan}@${PR_HOST}"
local current_dir="%B%F{blue}%~%f%b"
local rvm_ruby=''
if ${HOME}/.rvm/bin/rvm-prompt &> /dev/null; then # detect user-local rvm installation
rvm_ruby='%F{red}$(${HOME}/.rvm/bin/rvm-prompt i v g s)%f'
elif which rvm-prompt &> /dev/null; then # detect system-wide rvm installation
rvm_ruby='%F{red}$(rvm-prompt i v g s)%f'
elif which rbenv &> /dev/null; then # detect Simple Ruby Version Management
rvm_ruby='%F{red}$(rbenv version | sed -e "s/ (set.*$//")%f'
fi
local git_branch='$(git_prompt_info)'
PROMPT="${user_host} ${current_dir} ${rvm_ruby} ${git_branch}
─$PR_PROMPT "
RPROMPT="${return_code}"
ZSH_THEME_GIT_PROMPT_PREFIX="%F{yellow}"
ZSH_THEME_GIT_PROMPT_SUFFIX=" %f"
}

107
zsh/.zshrc Normal file
View File

@ -0,0 +1,107 @@
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=/home/sakhmatd/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="sakhmatd"
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion. Case
# sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"
# Uncomment the following line to disable bi-weekly auto-update checks.
#DISABLE_AUTO_UPDATE="true"
# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(wd)
source $ZSH/oh-my-zsh.sh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# ssh
# export SSH_KEY_PATH="~/.ssh/rsa_id"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# Automatically attach tmux session
if command -v tmux>/dev/null && xhost >& /dev/null; then
[[ ! $TERM =~ screen ]] && [ -z $TMUX] && { tmux attach || tmux new-session }
fi
# Make Xorg apps work in tmux
export DISPLAY=":0"
# Make me only type my key passwords once
if keychain --quiet; then
eval $(keychain --eval --quiet id_ed25519)
fi
# Print a fortune
echo
command fortune
echo
# Expots, Functions and Aliases
source /home/sakhmatd/.zshrc.local

114
zsh/.zshrc.local Normal file
View File

@ -0,0 +1,114 @@
## -*- mode: sh -*-
export RANGER_LOAD_DEFAULT_RC=FALSE
############################################################
## Exports
############################################################
export EDITOR='nvim'
export PAGER='less'
export BROWSER='qutebrowser'
# Add dotnet tools
# export PATH="$PATH:/home/sakhmatd/.dotnet/tools"
############################################################
## Functions
############################################################
# Transfer files to transfer.sh
transfer()
{
if [ $# -eq 0 ]; then
echo -e "No arguments specified.
Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer
test.md";
return 1;
fi
tmpfile=$( mktemp -t transferXXX );
if tty -s; then
basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g');
curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile;
else curl --progress-bar --upload-file "-" "https://transfer.sh/$1" >> $tmpfile ;
fi;
cat $tmpfile;
rm -f $tmpfile;
}
############################################################
## Aliases
############################################################
# neo- aliases
alias vim="nvim"
alias mutt='neomutt'
alias qemacs='emacs -q -nw'
alias sqemacs='sudo -q emacs -nw'
# Priv escalation
alias svim='sudo vim'
alias zzz='sudo zzz'
alias vm='sudo vm'
alias dmesg='sudo dmesg'
# Config files
alias fstab="$EDITOR /etc/fstab"
alias dwmconf="$EDITOR $DWM_CONF"
alias zshrcl="$EDITOR ~/.zshrc.local"
alias zshrc="$EDITOR ~/.zshrc"
alias muttrc="$EDITOR ~/.neomuttrc"
alias muttrcs="$EDITOR ~/.neomutt"
alias xinitrc="$EDITOR ~/.xinitrc"
# Convenience and helpers
alias h="history"
alias cd..="cd .."
alias reloadzsh="source ~/.zshrc.local"
alias rotatewacom='xsetwacom set "Wacom ISDv4 EC Pen stylus" Rotate'
alias myip='dig TXT +short o-o.myaddr.l.google.com @ns1.google.com'
alias watchsync='watch grep -e Dirty: -e Writeback: /proc/meminfo'
alias ducks='du -cks -h * | sort -rn | head -11'
alias speedtest='wget -O /dev/null http://speedtest.wdc01.softlayer.com/downloads/test10.zip'
alias cls='echo -ne "\033c"'
alias clearhistory='cat /dev/null > ~/.zsh_history && history -c && exit'
alias sshfs_mount='sshfs -C -o allow_other'
alias mountyadisk='sudo mount -t davfs https://webdav.yandex.ru /home/sakhmatd/mnt/yadisk'
alias mountallsync='sudo mount -t davfs https://cloud.allsync.com /home/sakhmatd/mnt/allsync'
############################################################
# OS-Specific Modules
############################################################
# FreeBSD
if [[ $(uname) == "FreeBSD" ]] then
# Fix FreeBSD's backspace behavior.
stty erase "^?"
# Package management
alias pkg='sudo pkg'
# BSD config files
alias bootloader.conf="sudo $EDITOR /boot/loader.conf"
alias rc.conf="sudo $EDITOR /etc/rc.conf"
alias sysctl.conf="sudo $EDITOR /etc/sysctl.conf"
fi
# Void Linux
if xbps-install -V &> /dev/null; then
alias xbps-install='sudo xbps-install'
fi
# ArchLinux
if pacman -V &> /dev/null; then
alias pacman='sudo pacman'
fi
# Slackware
if [[ -e /etc/slackware-release ]]; then
alias slapt-get='sudo slapt-get'
alias slackpkg='sudo slackpkg'
fi

5
zsh/README.md Normal file
View File

@ -0,0 +1,5 @@
Install [Oh My Zsh](https://ohmyz.sh) before using stow to install these files:
```
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
```