dotfiles/.config/nvim/init.vim_old

442 lines
11 KiB
Plaintext

set nocompatible " be iMproved, required
filetype off " required
call plug#begin()
Plug 'vim-scripts/c.vim'
Plug 'arcticicestudio/nord-vim'
Plug 'scrooloose/nerdtree'
Plug 'jistr/vim-nerdtree-tabs'
Plug 'rhysd/vim-clang-format'
Plug 'kana/vim-operator-user'
Plug 'rust-lang/rust.vim'
"Plug 'Shougo/deoplete.nvim'
"Plug 'zchee/deoplete-clang'
"Plug 'Shougo/deoplete-clangx'
"Plug 'Shougo/neoinclude.vim'
"Plug 'roxma/nvim-yarp'
"Plug 'sebastianmarkow/deoplete-rust'
"Plug 'carlitux/deoplete-flow'
Plug 'jpalardy/vim-slime'
"Plug 'autozimu/LanguageClient-neovim', {
" \ 'branch': 'next',
" \ 'do': 'bash install.sh',
" \ }
Plug 'calviken/vim-gdscript3'
"Plug 'Shougo/neosnippet'
"Plug 'Shougo/neosnippet-snippets'
Plug 'nikvdp/ejs-syntax'
Plug 'pangloss/vim-javascript'
Plug 'MaxMEllon/vim-jsx-pretty'
Plug 'jelera/vim-javascript-syntax'
"Plug 'w0rp/ale'
Plug 'prettier/prettier'
Plug 'flrnprz/plastic.vim'
Plug 'rakr/vim-one'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'vim-pandoc/vim-rmarkdown'
Plug 'vim-pandoc/vim-pandoc'
Plug 'vim-pandoc/vim-pandoc-syntax'
Plug 'junegunn/fzf.vim'
Plug 'tpope/vim-dadbod'
Plug 'lervag/vimtex'
Plug 'dpelle/vim-LanguageTool'
"Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'tikhomirov/vim-glsl'
Plug 'soli/prolog-vim'
Plug 'tpope/vim-dispatch'
"Plug 'rafcamlet/coc-nvim-lua'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'neovim/nvim-lspconfig'
Plug 'hrsh7th/nvim-compe'
Plug 'nvim-lua/lsp-status.nvim'
"Plug 'evanleck/vim-svelte', {'branch': 'main'}
Plug 'leafOfTree/vim-svelte-plugin'
Plug 'prettier/vim-prettier', { 'do': 'yarn install' }
call plug#end() " required
filetype plugin indent on " required
let g:prettier#config#tab_width = 2
lua <<EOF
require'nvim-treesitter.configs'.setup {
highlight = {
enable = true,
custom_captures = {
-- Highlight the @foo.bar capture group with the "Identifier" highlight group.
["foo.bar"] = "Identifier",
},
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false,
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = "gnn",
node_incremental = "grn",
scope_incremental = "grc",
node_decremental = "grm",
},
},
}
require'compe'.setup {
enabled = true;
autocomplete = true;
debug = false;
min_length = 1;
preselect = 'always';
throttle_time = 80;
source_timeout = 200;
resolve_timeout = 800;
incomplete_delay = 400;
max_abbr_width = 100;
max_kind_width = 100;
max_menu_width = 100;
documentation = {
border = { '', '' ,'', ' ', '', '', '', ' ' }, -- the border option is the same as `|help nvim_open_win|`
winhighlight = "NormalFloat:CompeDocumentation,FloatBorder:CompeDocumentationBorder",
max_width = 120,
min_width = 60,
max_height = math.floor(vim.o.lines * 0.3),
min_height = 1,
};
source = {
path = true;
buffer = true;
calc = true;
nvim_lsp = true;
nvim_lua = true;
vsnip = true;
ultisnips = true;
luasnip = true;
};
}
EOF
inoremap <silent><expr> <C-Space> compe#complete()
inoremap <silent><expr> <CR> compe#confirm('<CR>')
inoremap <silent><expr> <C-e> compe#close('<C-e>')
inoremap <silent><expr> <C-f> compe#scroll({ 'delta': +4 })
inoremap <silent><expr> <C-d> compe#scroll({ 'delta': -4 })
lua << END
local lsp_status = require('lsp-status')
lsp_status.register_progress()
local lspconfig = require('lspconfig')
-- Some arbitrary servers
lspconfig.clangd.setup({
handlers = lsp_status.extensions.clangd.setup(),
init_options = {
clangdFileStatus = true
},
on_attach = lsp_status.on_attach,
capabilities = lsp_status.capabilities
})
lspconfig.rust_analyzer.setup({
on_attach = lsp_status.on_attach,
capabilities = lsp_status.capabilities
})
lspconfig.pyright.setup({
on_attach = lsp_status.on_attach,
capabilities = lsp_status.capabilities
})
lspconfig.elmls.setup({
on_attach = lsp_status.on_attach,
capabilities = lsp_status.capabilities
})
lspconfig.svelte.setup({
on_attach = lsp_status.on_attach,
capabilities = lsp_status.capabilities
})
lspconfig.tsserver.setup({
on_attach = lsp_status.on_attach,
capabilities = lsp_status.capabilities
})
lspconfig.gdscript.setup({
on_attach = function (client)
local _notify = client.notify
client.notify = function (method, params)
if method == 'textDocument/didClose' then
-- Godot doesn't implement didClose yet
return
end
_notify(method, params)
end
lsp_status.on_attach(client)
end,
capabilities = lsp_status.capabilities,
flags = {
debounce_text_changes = 150,
}
})
END
" Statusline
function! LspStatus() abort
let status = luaeval('require("lsp-status").status()')
return trim(status)
endfunction
call airline#parts#define_function('lsp_status', 'LspStatus')
call airline#parts#define_condition('lsp_status', 'luaeval("#vim.lsp.buf_get_clients() > 0")')
let g:airline#extensions#nvimlsp#enabled = 0
let g:airline_section_x = airline#section#create_right(['lsp_status'])
" Errors in Red
hi LspDiagnosticsVirtualTextError guifg=red ctermfg=red
" Warnings in Yellow
hi LspDiagnosticsVirtualTextWarning guifg=yellow ctermfg=yellow
" Info and Hints in White
hi LspDiagnosticsVirtualTextInformation guifg=white ctermfg=white
hi LspDiagnosticsVirtualTextHint guifg=white ctermfg=white
" Underline the offending code
hi LspDiagnosticsUnderlineError guifg=NONE ctermfg=NONE cterm=underline gui=underline
hi LspDiagnosticsUnderlineWarning guifg=NONE ctermfg=NONE cterm=underline gui=underline
hi LspDiagnosticsUnderlineInformation guifg=NONE ctermfg=NONE cterm=underline gui=underline
hi LspDiagnosticsUnderlineHint guifg=NONE ctermfg=NONE cterm=underline gui=underline
lua << EOF
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics, {
-- Enable underline, use default values
underline = true,
-- Enable virtual text only on Warning or above, override spacing to 2
virtual_text = {
spacing = 2,
},
}
)
EOF
autocmd ColorScheme * :lua require('vim.lsp.diagnostic')._define_default_signs_and_highlights()
autocmd CursorHold * lua vim.lsp.diagnostic.show_line_diagnostics()
autocmd FileType matlab setlocal keywordprg=info\ octave\ --vi-keys\ --index-search
augroup filetypedetect
" Mail
autocmd BufRead,BufNewFile *mutt-* setfiletype mail
autocmd BufRead,BufNewFile *.gd set filetype=gdscript3
augroup END
let g:languagetool_jar = "/home/daan/.local/share/LanguageTool-5.2-SNAPSHOT/languagetool-commandline.jar"
let g:jsx_ext_required = 0
let g:neosnippet#enable_completed_snippet = 1
let g:autocomplete_flow#insert_paren_after_function = 0
let g:fzf_buffers_jump = 1
"let g:coc_filetype_map = {
"\ 'md': 'tex',
"\ }
set tags+=./.tags
set nobackup
set nowritebackup
set guifont=Fira\ Code:h12
"Credit joshdick
"Use 24-bit (true-color) mode in Vim/Neovim when outside tmux.
"If you're using tmux version 2.2 or later, you can remove the outermost $TMUX check and use tmux's 24-bit color support
"(see < http://sunaku.github.io/tmux-24bit-color.html#usage > for more information.)
if (empty($TMUX))
if (has("nvim"))
"For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
endif
"For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
"Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
" < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
if (has("termguicolors"))
set termguicolors
endif
endif
let g:airline_powerline_fonts = 1
" Session management
set switchbuf=useopen,usetab
let g:session = 0
fu! AutoSaveSess()
if g:session == 1
call SaveSess()
endif
endfunction
fu! SaveSess()
execute 'NERDTreeTabsClose'
execute 'mksession! ' . getcwd() . '/.session.vim'
let g:session = 1
endfunction
fu! RemoveSess()
shell "rm " . getcwd() . "/.session.vim"
endfunction
fu! RestoreSess()
if filereadable(getcwd() . '/.session.vim')
let initial_args = argv()
execute 'so ' . getcwd() . '/.session.vim'
for file in initial_args
if bufloaded(file) != 1
execute 'tabnew ' . getcwd() . '/' . file
else
execute 'sb ' . file
endif
endfor
let g:session = 1
endif
endfunction
:command Savesess call SaveSess()
:command Restoresess call RestoreSess()
:command Removesess call RemoveSess()
nnoremap <A-r> :Restoresess<cr>
" Save session on quitting Vim
autocmd VimLeave * call AutoSaveSess()
" Restore session on starting Vim
"autocmd VimEnter * nested call RestoreSess()
"----------------------
" move between tabs
nnoremap <A-h> :tabprevious<CR>
nnoremap <A-l> :tabnext<CR>
map <C-n> :NERDTreeMirrorToggle<CR>
" prevent mouse vanishing
set nomousehide
" toggles menu in graphical mode
function! ToggleGUICruft()
if &guioptions=='ir'
exec('set guioptions=imrLn')
else
exec('set guioptions=ir')
endif
endfunction
map <F12> <Esc>:call ToggleGUICruft()<cr>
set number
set linebreak
set nobackup
set noswapfile
"set shortmess+=I
set backspace=indent,eol,start
set visualbell t_vb=
set showmode
"set smartcase
nnoremap <F1> <nop>
nnoremap Q <nop>
nnoremap K <nop>
runtime! ftplugin/man.vim
nnoremap K :Man <cword>
set mouse=a
set nu
let g:clang_format#code_style="llvm"
set clipboard=unnamed
set backspace=indent,eol,start " allow backspacing over everything in insert mode
cmap w!! w !sudo tee > /dev/null %
set laststatus=2
let g:nord_uniform_diff_background = 1
let g:nord_cursor_line_number_background = 1
"let g:lightline = {
"\ 'colorscheme': 'one',
"\ }
let g:airline_theme='one'
set background=dark
colorscheme one
filetype plugin indent on
set smartindent
set tabstop=4
set shiftwidth=4
set expandtab
:set number relativenumber
:set nu rnu
:augroup numbertoggle
: autocmd!
: autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
: autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
:augroup END
:command WQ wq
:command Wq wq
:command W w
:command Q q
:command WQa wqa
:command Wqa wqa
" Terminal stuff
:tnoremap <Esc> <C-\><C-n>
:set ma
let g:C_Mapfeader = ','
"let g:coc_snippet_next = '<tab>'
nnoremap <C-f> :Files<cr>
nnoremap <C-b> :Buffers<cr>
nnoremap ,s :split<cr>
nnoremap .s :vsplit<cr>
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" Disable arrow keys
map <Up> <Esc>
map <Down> <Esc>
map <Left> <Esc>
map <Right> <Esc>
imap <Up> <Esc>
imap <Down> <Esc>
imap <Left> <Esc>
imap <Right> <Esc>
set completeopt=menuone,noselect