Python working

This commit is contained in:
Anthony Cicchetti 2019-11-14 20:09:04 -05:00
parent 3ed34f85e8
commit 5fd8defa85
2 changed files with 77 additions and 25 deletions

View file

@ -1,7 +1,7 @@
# set default terminal
#set -ga terminal-overrides ",xterm-kitty:Tc,alacritty:Tc,xterm-termite:Tc"
set-option -g default-terminal "tmux-256color"
set-option -sa terminal-overrides ',xterm-256color:RGB'
set-option -sa terminal-overrides ',xterm-256color:RGB,alacritty:RGB'
# set mouse/history stuff
set -g mouse on
set -g history-limit 20000

100
vim/vimrc
View file

@ -4,6 +4,8 @@ if empty(glob('~/.config/nvim/autoload/plug.vim'))
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
let g:pyxversion = 'python3'
set number
set relativenumber
set tabstop=4
@ -61,20 +63,39 @@ Plug 'prabirshrestha/async.vim'
call plug#end()
function! s:writebuffer(bufname, text)
let l:bufnum = bufwinnr(a:bufname)
if l:bufnum == -1
execute "vsplit" a:bufname
setlocal buftype=nofile
else
execute l:bufnum . 'wincmd w'
endif
call append(0, a:text)
endfunction
function! s:handlegeneric(cmd, job_id, data, event_type)
if a:event_type == 'exit'
echo a:cmd . ' completed successfully'
elseif a:event_type == 'stdout' && len(a:data) > 1
call s:writebuffer('__STDOUT__', a:data)
elseif a:event_type == 'stderr' && len(a:data) > 1
call s:writebuffer('__STDERR__', a:data)
endif
endfunction
"Setting up coc-tools
function! s:handlestdout(job_id, data, event_type)
endfunction
function! s:handlestderr(job_id, data, event_type)
endfunction
function! s:handleexitpyls(job_id, data, event_type)
echo 'pyls installed'
function! s:handlepython(job_id, data, event_type)
call s:handlegeneric('pip install python-language-server pynvim', a:job_id, a:data, a:event_type)
endfunction
function! s:handleexitsolargraph(job_id, data, event_type)
echo 'solargraph installed'
echo 'solargraph & neovim installed'
endfunction
function! s:handleexitnode(job_id, data, event_type)
echo 'node-host installed'
endfunction
function! s:cmdexitcode(cmd)
@ -83,28 +104,60 @@ function! s:cmdexitcode(cmd)
endfunction
function! s:ensurePython()
if (s:cmdexitcode('pyls -h'))
let jobid = async#job#start(['pip', 'install', 'python-language-server'], {
\ 'on_stdout': function('s:handlestdout'),
\ 'on_stderr': function('s:handlestderr'),
\ 'on_exit': function('s:handleexitpyls')
if (s:cmdexitcode('pyls -h') || s:cmdexitcode('python -c "import neovim"'))
let l:jobid = async#job#start(['pip', 'install', 'python-language-server', 'pynvim'], {
\ 'on_stdout': function('s:handlepython'),
\ 'on_stderr': function('s:handlepython'),
\ 'on_exit': function('s:handlepython')
\ })
au VimEnter * CocInstall coc-python
endif
execute 'CocInstall coc-python'
endfunction
function! s:ensureRuby()
if (s:cmdexitcode('solargraph -v'))
let jobid = async#job#start(['gem', 'install', 'solargraph'], {
if (s:cmdexitcode('solargraph -v && ruby -e "require \"neovim\""'))
let l:jobid = async#job#start(['gem', 'install', 'solargraph', 'neovim'], {
\ 'on_stdout': function('s:handlestdout'),
\ 'on_stderr': function('s:handlestderr'),
\ 'on_exit': function('s:handleexitsolargraph')
\ })
au VimEnter * CocInstall coc-solargraph
endif
endfunction
function! s:ensureNode()
if (s:cmdexitcode('neovim-node-host --version'))
let l:jobid = async#job#start(['yarn', 'global', 'add', 'neovim'], {
\ 'on_stdout': function('s:handlestdout'),
\ 'on_stderr': function('s:handlestderr'),
\ 'on_exit': function('s:handleexitnode')
\})
au VimEnter * CocInstall coc-tsserver
endif
endfunction
call s:ensurePython()
call s:ensureRuby()
call s:ensureNode()
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
inoremap <silent><expr> <c-space> coc#refresh()
autocmd CursorHold * silent call CocActionAsync('highlight')
command! -nargs=0 Format :call CocAction('format')
command! -nargs=1 WriteBuffer :call Writebuffer(<args>)
"Gruvbox config
" colorscheme gruvbox
@ -123,22 +176,21 @@ nnoremap <leader>h <C-W><C-H>
nnoremap <leader>j <C-W><C-J>
nnoremap <leader>k <C-W><C-K>
nnoremap <leader>l <C-W><C-L>
nnoremap <leader>n :nohl
nnoremap <C-k> <C-u>
nnoremap <C-j> <C-d>
"ALE Keymaps and options
"nnoremap <silent> <leader><Space>a a<C-X><C-O>
"nnoremap <silent> <leader><Space>g :ALEGoToDefinition<CR>
"nnoremap <silent> <leader><Space>f :ALEFix<CR>
"Coc Keymaps and options
nnoremap <silent> <leader><Space>d <Plug>(coc-definition)
nnoremap <silent> <leader><Space>g <Plug>(coc-type-definition)
"which-key
let g:which_key_map = {}
autocmd! User vim-which-key call which_key#register('<Space>', 'g:which_key_map')
let g:which_key_map[' '] = {
\ 'name' : '+ale' ,
\ 'a' : 'completions' ,
\ 'd' : 'definition' ,
\ 'g' : 'go-to-definition' ,
\ 'f' : 'fix' ,
\ }
call which_key#register('<Space>', "g:which_key_map")
nnoremap <silent> <leader> :<c-u>WhichKey '<Space>'<CR>