From 3f720e882d3f98d061b53d000eef7b50d8ac3bed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Mon, 8 Jul 2019 07:57:29 +0200 Subject: [PATCH 1/3] Vim, mostly --- config/mypy/config | 6 ++ config/scripts/mel | 2 +- config/scripts/ovhcli | 59 ++++++++++++++++++ config/vim/{pluginconfig => pluginconfig.vim} | 61 +++++++++++++------ config/vim/{plugins => pluginlist.vim} | 31 +++++++--- config/vim/{vimconfig => vimconfig.vim} | 1 + config/vim/vimrc | 6 +- 7 files changed, 136 insertions(+), 30 deletions(-) create mode 100644 config/mypy/config create mode 100755 config/scripts/ovhcli rename config/vim/{pluginconfig => pluginconfig.vim} (54%) rename config/vim/{plugins => pluginlist.vim} (74%) rename config/vim/{vimconfig => vimconfig.vim} (98%) diff --git a/config/mypy/config b/config/mypy/config new file mode 100644 index 0000000..88f2fe6 --- /dev/null +++ b/config/mypy/config @@ -0,0 +1,6 @@ +[mypy] +ignore_missing_imports = True +disallow_untyped_defs = True +disallow_untyped_calls = True +disallow_incomplete_defs = True +disallow_untyped_decorators = True diff --git a/config/scripts/mel b/config/scripts/mel index 04ed91a..693d6c2 100755 --- a/config/scripts/mel +++ b/config/scripts/mel @@ -603,6 +603,6 @@ if __name__ == "__main__": perfstep("exec") # DEBUG - sys.exit(0) for kv in sorted(perf_dict.items(), key=lambda p: p[1]): log.debug("{1:.6f} {0}".format(*kv)) + sys.exit(0) diff --git a/config/scripts/ovhcli b/config/scripts/ovhcli new file mode 100755 index 0000000..f081737 --- /dev/null +++ b/config/scripts/ovhcli @@ -0,0 +1,59 @@ +#!/usr/bin/env python3 + +import os +import ovh +import xdg.BaseDirectory +import urllib.request +from pprint import pprint +import json +import logging +import coloredlogs +import argparse + +coloredlogs.install(level='DEBUG', fmt='%(levelname)s %(message)s') +log = logging.getLogger() + +debug = None + +class OvhCli(): + ROOT = "https://api.ovh.com/1.0?null" + def __init__(self): + self.cacheDir = os.path.join(xdg.BaseDirectory.xdg_cache_home, 'ovhcli') + # TODO Corner cases: links, cache dir not done, configurable cache + if not os.path.isdir(self.cacheDir): + assert not os.path.exists(self.cacheDir) + os.makedirs(self.cacheDir) + + def updateCache(self): + log.info("Downloading the API description") + rootJsonPath = os.path.join(self.cacheDir, 'root.json') + log.debug(f"{self.ROOT} -> {rootJsonPath}") + urllib.request.urlretrieve(self.ROOT, rootJsonPath) + with open(rootJsonPath, 'rt') as rootJson: + root = json.load(rootJson) + basePath = root['basePath'] + + for apiRoot in root['apis']: + fmt = 'json' + assert fmt in apiRoot['format'] + path = apiRoot['path'] + schema = apiRoot['schema'].format(format=fmt, path=path) + apiJsonPath = os.path.join(self.cacheDir, schema[1:]) + apiJsonUrl = basePath + schema + log.debug(f"{apiJsonUrl} -> {apiJsonPath}") + apiJsonPathDir = os.path.dirname(apiJsonPath) + if not os.path.isdir(apiJsonPathDir): + os.makedirs(apiJsonPathDir) + urllib.request.urlretrieve(apiJsonUrl, apiJsonPath) + + def createParser(self): + parser = argparse.ArgumentParser(description='Access the OVH API') + return parser + + +if __name__ == '__main__': + cli = OvhCli() + # cli.updateCache() + parser = cli.createParser() + args = parser.parse_args() + print(args) diff --git a/config/vim/pluginconfig b/config/vim/pluginconfig.vim similarity index 54% rename from config/vim/pluginconfig rename to config/vim/pluginconfig.vim index 907872a..e41c738 100644 --- a/config/vim/pluginconfig +++ b/config/vim/pluginconfig.vim @@ -8,7 +8,7 @@ let g:ale_completion_enabled = 1 let g:ale_fixers = ['autopep8', 'shfmt', 'uncrustify', 'remove_trailing_lines', 'trim_whitespace', 'phpcbf'] let g:ale_php_phpcs_standard = '/srv/http/machines/ruleset.xml' -" For PHP, install https://pear.php.net/package/PHP_CodeSniffer +" For PHP, install https://pear.php.net/package/PHP_CodeSniffer """ UNDOTREE """ @@ -24,14 +24,15 @@ nmap :TagbarToggle set noshowmode set laststatus=2 let g:airline_powerline_fonts = 1 -" let g:airline#extensions#syntastic#enabled = 1 let g:airline#extensions#tabline#enabled = 1 let g:airline_section_a = airline#section#create(['mode']) let g:airline_section_b = airline#section#create(['branch', 'hunks']) " let g:airline_section_z = airline#section#create(['%B', '@', '%l', ':', '%c']) let g:airline_theme = 'base16_monokai' -let g:airline#extensions#ale#enabled = 1 + +let airline#extensions#languageclient#error_symbol = '✖ ' +let airline#extensions#languageclient#warning_symbol = '⚠ ' """ FZF """ @@ -51,27 +52,28 @@ let g:fzf_colors = \ 'spinner': ['fg', 'Label'], \ 'header': ['fg', 'Comment'] } -nmap gF :Files -nmap gf :GFiles -nmap gb :Buffers -nmap gL :Lines -nmap gl :BLines -nmap gT :Tags -nmap gt :BTags -nmap gm :Marks -nmap gw :Windows -nmap gh :History -nmap gH :History: -nmap gS :History/ -nmap gs :Snippets +let g:fzf_command_prefix = 'Fzf' +nmap gF :FzfFiles +nmap gf :FzfGFiles +nmap gb :FzfBuffers +nmap gL :FzfLines +nmap gl :FzfBLines +nmap gT :FzfTags +nmap gt :FzfBTags +nmap gm :FzfMarks +nmap gw :FzfWindows +nmap gh :FzfHistory +nmap gH :FzfHistory: +nmap gS :FzfHistory/ +nmap gs :FzfSnippets " TODO `gd` → go to tag matching selected word, or show a list with that " of tags pre-filtered with that word """ SUPERTAB """ -let g:SuperTabDefaultCompletionType = "" " Go down when completing -let g:SuperTabContextDefaultCompletionType = "" +" let g:SuperTabDefaultCompletionType = "" " Go down when completing +" let g:SuperTabContextDefaultCompletionType = "" """ LanguageTool """ @@ -82,3 +84,26 @@ let g:pandoc#modules#disabled = ["folding"] let g:pandoc#spell#enabled = 0 let g:pandoc#syntax#conceal#use = 0 +""" LanguageClient-neovim """ + +let g:LanguageClient_serverCommands = { + \ 'python': ['pyls'], + \ } + + +function LC_maps() + if has_key(g:LanguageClient_serverCommands, &filetype) + nnoremap K :call LanguageClient#textDocument_hover() + nnoremap gd :call LanguageClient#textDocument_definition() + nnoremap gd :call LanguageClient#textDocument_references() + nnoremap :call LanguageClient#textDocument_rename() + nnoremap :call LanguageClient#textDocument_formatting() + set completefunc=LanguageClient#complete + set omnifunc=LanguageClient#complete + endif +endfunction +autocmd FileType * call LC_maps() + +""" deoplete """ + +let g:deoplete#enable_at_startup = 1 diff --git a/config/vim/plugins b/config/vim/pluginlist.vim similarity index 74% rename from config/vim/plugins rename to config/vim/pluginlist.vim index 4af9816..d7a208f 100644 --- a/config/vim/plugins +++ b/config/vim/pluginlist.vim @@ -34,15 +34,24 @@ Plug 'tomtom/tcomment_vim' " Plug 'tomlion/vim-solidity' " Plug 'godlygeek/tabular' " Plug 'jrozner/vim-antlr' + +" When in f/F/t/T mode, highlight in red the characters that can be jumped to +Plug 'deris/vim-shot-f' + +" Auto-highlight one character per word for quick f/F movement +Plug 'unblevable/quick-scope' + " " Plug 'maralla/completor.vim' -" if has('nvim') -" Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } -" else -" Plug 'Shougo/deoplete.nvim' -" Plug 'roxma/nvim-yarp' -" Plug 'roxma/vim-hug-neovim-rpc' -" endif +" +" Auto-completion +if has('nvim') + Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } +else + Plug 'Shougo/deoplete.nvim' + Plug 'roxma/nvim-yarp' + Plug 'roxma/vim-hug-neovim-rpc' +endif " Plug 'zchee/deoplete-jedi' " Plug 'python-mode/python-mode', { 'branch': 'develop' } @@ -54,7 +63,13 @@ Plug 'terryma/vim-smooth-scroll' Plug 'vim-pandoc/vim-pandoc' Plug 'vim-pandoc/vim-pandoc-syntax' Plug 'idanarye/vim-vebugger' -Plug 'w0rp/ale' + +" Language Server Procotol client +Plug 'autozimu/LanguageClient-neovim', { + \ 'branch': 'next', + \ 'do': 'bash install.sh', + \ } + call plug#end() diff --git a/config/vim/vimconfig b/config/vim/vimconfig.vim similarity index 98% rename from config/vim/vimconfig rename to config/vim/vimconfig.vim index 97078df..1ac3679 100644 --- a/config/vim/vimconfig +++ b/config/vim/vimconfig.vim @@ -40,6 +40,7 @@ set splitbelow " Turn off relativenumber only for insert mode. if has('nvim') + set relativenumber augroup every autocmd! au InsertEnter * set norelativenumber diff --git a/config/vim/vimrc b/config/vim/vimrc index 4dcfe5e..ae07883 100644 --- a/config/vim/vimrc +++ b/config/vim/vimrc @@ -7,7 +7,7 @@ filetype on set runtimepath+=~/.config/vim,~/.cache/vim set viminfo+=n~/.cache/vim/viminfo -source ~/.config/vim/plugins -source ~/.config/vim/pluginconfig -source ~/.config/vim/vimconfig +source ~/.config/vim/pluginlist.vim +source ~/.config/vim/pluginconfig.vim +source ~/.config/vim/vimconfig.vim From fa418e9e11ca7c2db3de81002426af0548a7c92c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Mon, 8 Jul 2019 11:01:46 +0200 Subject: [PATCH 2/3] Internship stuff --- config/tmux.conf | 2 +- config/vim/plugins | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/config/tmux.conf b/config/tmux.conf index 9c9f7d9..c5aa3a9 100644 --- a/config/tmux.conf +++ b/config/tmux.conf @@ -9,7 +9,7 @@ bind-key -n M-7 select-window -t 7 bind-key -n M-8 select-window -t 8 bind-key -n M-9 select-window -t 9 -set -g mouse on +set -g mouse off # https://superuser.com/a/1007721 bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e; send-keys -M'" diff --git a/config/vim/plugins b/config/vim/plugins index 4af9816..6b4ca8f 100644 --- a/config/vim/plugins +++ b/config/vim/plugins @@ -56,5 +56,8 @@ Plug 'vim-pandoc/vim-pandoc-syntax' Plug 'idanarye/vim-vebugger' Plug 'w0rp/ale' +" Automatically closes brackets, quotes and parentheses +Plug 'jiangmiao/auto-pairs' + call plug#end() From 384460ec29dd59c1de6733a234655d5ba63d888f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Tue, 16 Jul 2019 17:43:46 +0200 Subject: [PATCH 3/3] Fixed tmux config --- config/shell/shenv | 9 +++++++++ config/shell/shrc | 2 +- config/{ => tmux}/tmux.conf | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) rename config/{ => tmux}/tmux.conf (84%) diff --git a/config/shell/shenv b/config/shell/shenv index 7a9f2c8..ebb8a19 100644 --- a/config/shell/shenv +++ b/config/shell/shenv @@ -77,6 +77,15 @@ export XAUTHORITY="$HOME/.config/Xauthority" # And for the rest, see aliases direnv JUNKHOME "$HOME/.cache/junkhome" +# For software that did not understand that XDG variables have defaults +direnv XDG_DATA_HOME "$HOME/.local/share" +direnv XDG_CONFIG_HOME "$HOME/.config" +export XDG_DATA_DIRS="/usr/local/share/:/usr/share/" +export XDG_CONFIG_DIRS="/etc/xdg" +direnv XDG_CACHE_HOME "$HOME/.cache" +direnv XDG_RUNTIME_DIR "$HOME/.local/run" +chmod 0700 "$XDG_RUNTIME_DIR" + # Path # Function stolen from Arch Linux /etc/profile diff --git a/config/shell/shrc b/config/shell/shrc index 7fa3871..51461b8 100644 --- a/config/shell/shrc +++ b/config/shell/shrc @@ -54,7 +54,7 @@ alias bower='bower --config.storage.packages=~/.cache/bower/packages --config.st alias gdb='gdb -x $HOME/.config/gdbinit' alias iftop='iftop -c $HOME/.config/iftoprc' alias lmms='lmms --config $HOME/.config/lmmsrc.xml' -alias tmux='tmux -f $HOME/.config/tmux.conf' +alias tmux='tmux -f $HOME/.config/tmux/tmux.conf' # TODO ruby's gem when I find a use for it diff --git a/config/tmux.conf b/config/tmux/tmux.conf similarity index 84% rename from config/tmux.conf rename to config/tmux/tmux.conf index c5aa3a9..1eb28a4 100644 --- a/config/tmux.conf +++ b/config/tmux/tmux.conf @@ -23,4 +23,6 @@ set -g @themepack 'powerline/block/green' set-environment -g TMUX_PLUGIN_MANAGER_PATH '~/.cache/tmuxplugins/' # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) +if "test ! -d ~/.cache/tmuxplugins/tpm" \ + "run 'git clone https://github.com/tmux-plugins/tpm ~/.cache/tmuxplugins/tpm && ~/.cache/tmuxplugins/tpm/bin/install_plugins'" run -b '~/.cache/tmuxplugins/tpm/tpm'