467 lines
13 KiB
VimL
467 lines
13 KiB
VimL
"===============================================================================
|
|
"======================== NVIM Main Configuration File =========================
|
|
"===============================================================================
|
|
|
|
|
|
|
|
"================================ General Setup ================================
|
|
"===============================================================================
|
|
" This section contains seme stuff I just want in general.
|
|
|
|
inoremap jk <Esc>
|
|
" Automatic expansion of comments.
|
|
set formatoptions=rqn1
|
|
" Disable mouse.
|
|
set mouse=""
|
|
" Plain old cursor in every mode.
|
|
set guicursor=
|
|
|
|
" Use a different mapleader.
|
|
let mapleader=' '
|
|
|
|
" Don't use arrow keys unless in command mode.
|
|
inoremap <Up> <Nop>
|
|
inoremap <Down> <Nop>
|
|
inoremap <Left> <Nop>
|
|
inoremap <Right> <Nop>
|
|
nnoremap <Up> <Nop>
|
|
nnoremap <Down> <Nop>
|
|
nnoremap <Left> <Nop>
|
|
nnoremap <Right> <Nop>
|
|
vnoremap <Up> <Nop>
|
|
vnoremap <Down> <Nop>
|
|
vnoremap <Left> <Nop>
|
|
vnoremap <Right> <Nop>
|
|
" I disabled this, since the shell requires arrow keys...
|
|
"tnoremap <Up> <Nop>
|
|
"tnoremap <Down> <Nop>
|
|
"tnoremap <Left> <Nop>
|
|
"tnoremap <Right> <Nop>
|
|
|
|
" Getting out of the terminal insert mode is extremely awkward.
|
|
" This mapping solves that.
|
|
tnoremap <Esc><Esc> <C-\><C-n>
|
|
|
|
" Use UTF-8, because we don't live in 1783 anymore.
|
|
set encoding=UTF-8
|
|
|
|
" Why would everything remain highlighted all the time?
|
|
set nohlsearch
|
|
|
|
" Relative numbers are great.
|
|
set number relativenumber
|
|
|
|
" I user :terminal quite often.
|
|
nnoremap <leader>t :sp<Cr>:terminal<Cr>a
|
|
nnoremap <leader>T :vsp<Cr>:terminal<Cr>a
|
|
|
|
"========================= Code Style Related Settings =========================
|
|
"===============================================================================
|
|
|
|
" This is basically Python's recommendation.
|
|
set tabstop=4
|
|
set softtabstop=0
|
|
set shiftwidth=4
|
|
set expandtab
|
|
|
|
|
|
"======================== Filetype And Related Settings ========================
|
|
"===============================================================================
|
|
" This section contains stuff that is related to file types.
|
|
|
|
filetype plugin on
|
|
|
|
set modeline
|
|
set modelines=10
|
|
|
|
autocmd BufEnter *.json set formatprg=python3\ -m\ json.tool
|
|
|
|
|
|
"_______________________________________________________________________________
|
|
"=========================== Installing all Plugins ============================
|
|
"===============================================================================
|
|
" For reasons this has to been done in a single step.
|
|
|
|
call plug#begin('~/.vim/plugged')
|
|
" This is for the LSP stuff.
|
|
Plug 'neovim/nvim-lspconfig'
|
|
Plug 'anott03/nvim-lspinstall'
|
|
Plug 'nvim-lua/lsp-status.nvim'
|
|
|
|
Plug 'hrsh7th/cmp-nvim-lsp'
|
|
Plug 'hrsh7th/cmp-buffer'
|
|
Plug 'hrsh7th/cmp-path'
|
|
Plug 'hrsh7th/cmp-cmdline'
|
|
Plug 'hrsh7th/nvim-cmp'
|
|
|
|
Plug 'quangnguyen30192/cmp-nvim-ultisnips'
|
|
|
|
" Inserting unicode characters.
|
|
Plug 'chrisbra/unicode.vim'
|
|
|
|
" Color schemes.
|
|
Plug 'tomasr/molokai'
|
|
Plug 'bluz71/vim-moonfly-colors'
|
|
Plug 'bluz71/vim-nightfly-guicolors'
|
|
Plug 'sainnhe/sonokai'
|
|
Plug 'dylnmc/vulpo.vim'
|
|
|
|
" This is for snippets.
|
|
Plug 'SirVer/ultisnips'
|
|
|
|
" Treesitter seems to be a reall nice
|
|
" plugin for code highlighting.
|
|
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
|
|
|
|
" This should highlight python docstrings.
|
|
Plug 'stsewd/sphinx.nvim', { 'do': ':UpdateRemotePlugins' }
|
|
|
|
" SLIME brings REPL features to VIM.
|
|
" I will try this out.
|
|
Plug 'jpalardy/vim-slime'
|
|
|
|
" This plugin should allow editing Jupyter Notebooks
|
|
" in VIM.
|
|
Plug 'szymonmaszke/vimpyter'
|
|
|
|
" Firenvim allows to use neovim as the
|
|
" firefox text editor.
|
|
Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } }
|
|
|
|
" This is a tree manager
|
|
Plug 'kyazdani42/nvim-web-devicons'
|
|
Plug 'kyazdani42/nvim-tree.lua'
|
|
|
|
" Git Gut.
|
|
Plug 'airblade/vim-gitgutter'
|
|
|
|
" Vimtex for a better TeX experience
|
|
Plug 'lervag/vimtex'
|
|
|
|
" Table mode
|
|
Plug 'dhruvasagar/vim-table-mode'
|
|
|
|
" Snakemake
|
|
Plug 'snakemake/snakemake', {'rtp': 'misc/vim'}
|
|
call plug#end()
|
|
|
|
"======================== Language Server Configuration ========================
|
|
"===============================================================================
|
|
" This section sets up the language server for the languages I use.
|
|
|
|
" Run this to install pyls if you haven't yet.
|
|
"LspInstall pyls
|
|
"LspInstall bashls
|
|
|
|
" Install ccls from snap or flatpack.
|
|
lua << EOF
|
|
|
|
local nvim_lsp_status = require('lsp-status')
|
|
nvim_lsp_status.register_progress()
|
|
local nvim_lsp = require('lspconfig')
|
|
|
|
-- This basically enables autocompletion
|
|
local on_attach = function(_, bufnr)
|
|
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
|
--require'completion'.on_attach(_, bufnr)
|
|
-- also attach lsp-status
|
|
nvim_lsp_status.on_attach(_, bufnr)
|
|
end
|
|
|
|
-- Enable the language servers.
|
|
--nvim_lsp.ccls.setup{on_attach=on_attach, capabilities=nvim_lsp_status.capabilities}
|
|
nvim_lsp.clangd.setup{on_attach=on_attach
|
|
, capabilities=nvim_lsp_status.capabilities
|
|
--, flags = { debounce_text_changes = 150, }
|
|
}
|
|
--nvim_lsp.vimls.setup{on_attach=on_attach, capabilities=nvim_lsp_status.capabilities}
|
|
nvim_lsp.pylsp.setup{on_attach=on_attach, capabilities=nvim_lsp_status.capabilities}
|
|
nvim_lsp.bashls.setup{on_attach=on_attach, capabilities=nvim_lsp_status.capabilities}
|
|
--nvim_lsp.yamlls.setup{on_attach=on_attach, capabilities=nvim_lsp_status.capabilities}
|
|
nvim_lsp.texlab.setup{on_attach=on_attach, capabilities=nvim_lsp_status.capabilities}
|
|
nvim_lsp.rust_analyzer.setup{on_attach=on_attach, capabilities=nvim_lsp_status.capabilities}
|
|
|
|
EOF
|
|
|
|
|
|
" Highlight the problems in the code.
|
|
highlight LspDiagnosticsDefaultError guifg=BrightRed
|
|
highlight LspDiagnosticsDefaultWarning guifg=BrightYellow
|
|
|
|
" This allows to jump to the definition, and
|
|
" show some documentation respectively.
|
|
nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>
|
|
nnoremap <silent> gD <cmd>lua vim.lsp.buf.declaration()<CR>
|
|
nnoremap <silent> gh <cmd>lua vim.lsp.buf.hover()<CR>
|
|
nnoremap <silent> gi <cmd>lua vim.lsp.buf.implementation()<CR>
|
|
nnoremap <silent> <leader>ca <cmd>lua vim.lsp.buf.code_action()<CR>
|
|
nnoremap <silent> <leader>rn <cmd>lua vim.lsp.buf.rename()<CR>
|
|
nnoremap <silent> [d <cmd>lua vim.lsp.diagnostic.goto_prev()<CR>
|
|
nnoremap <silent> ]d <cmd>lua vim.lsp.diagnostic.goto_next()<CR>
|
|
|
|
|
|
" This part sets up lsp diagnostics.
|
|
lua << EOF
|
|
|
|
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
|
|
vim.lsp.diagnostic.on_publish_diagnostics, {
|
|
underline = true
|
|
, update_in_insert = true
|
|
-- This sets the spacing and the prefix, obviously.
|
|
, virtual_text = {
|
|
spacing = 4
|
|
, prefix = '🔙'
|
|
}
|
|
})
|
|
|
|
EOF
|
|
" Statusline
|
|
function! LspStatus() abort
|
|
if luaeval('#vim.lsp.buf_get_clients() > 0')
|
|
return luaeval("require('lsp-status').status()")
|
|
endif
|
|
|
|
return ''
|
|
endfunction
|
|
|
|
function MyLspStatus()
|
|
let tmp = LspStatus()
|
|
return tmp
|
|
endfunction
|
|
|
|
"========================= Settings For Autocompletion =========================
|
|
"===============================================================================
|
|
|
|
" This prevents vim from inserting random function heads,
|
|
" and also gives some documentation preview.
|
|
set completeopt=menuone,noinsert,noselect
|
|
|
|
lua << EOF
|
|
|
|
local cmp = require'cmp'
|
|
cmp.setup({
|
|
snippet = {
|
|
expand = function(args)
|
|
vim.fn["UltiSnips#Anon"](args.body)
|
|
end,
|
|
},
|
|
mapping = {
|
|
['<C-n>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
|
|
['<C-p>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
|
|
--['<Down>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }),
|
|
--['<Up>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }),
|
|
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
|
['<C-Space>'] = cmp.mapping.complete(),
|
|
['<C-e>'] = cmp.mapping.close(),
|
|
['<CR>'] = cmp.mapping.confirm({
|
|
behavior = cmp.ConfirmBehavior.Replace,
|
|
select = true,
|
|
}),
|
|
},
|
|
sources = cmp.config.sources({
|
|
{ name = 'nvim_lsp' },
|
|
{ name = 'ultisnips' },
|
|
{ name = 'buffer' },
|
|
}),
|
|
})
|
|
|
|
--local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
|
-- -- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
|
|
-- require('lspconfig')['<YOUR_LSP_SERVER>'].setup {
|
|
-- capabilities = capabilities
|
|
-- }
|
|
|
|
EOF
|
|
|
|
|
|
|
|
"============================ A Nice Color Scheme ==============================
|
|
"===============================================================================
|
|
|
|
"set background=dark
|
|
"let g:airline_theme='one'
|
|
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
|
|
set termguicolors
|
|
" This is for sonokai, a rather nice
|
|
" color scheme.
|
|
"let g:sonokai_style = 'atlantis'
|
|
"let g:sonokai_enable_italic = 0
|
|
"let g:sonokai_disable_italic_comment = 0
|
|
colorscheme molokai
|
|
|
|
"====================== Settings Related to Highlighting =======================
|
|
"===============================================================================
|
|
|
|
let g:vimsyn_embed = 'l'
|
|
|
|
|
|
"======================= Settings Related to Treesitter ========================
|
|
"===============================================================================
|
|
|
|
" Install the language parsers.
|
|
"TSInstall python
|
|
"TSInstall c
|
|
"TSInstall cpp
|
|
"TSInstall bash
|
|
|
|
|
|
lua <<EOF
|
|
require'nvim-treesitter.configs'.setup {
|
|
highlight = {
|
|
enable = true,
|
|
disable = {"latex"},
|
|
},
|
|
-- indent = {
|
|
-- enable = true,
|
|
-- },
|
|
fold = {
|
|
enable = true,
|
|
},
|
|
rainbow = {
|
|
enable = true,
|
|
extended_mode = true,
|
|
max_file_lines = nil,
|
|
},
|
|
}
|
|
EOF
|
|
set foldmethod=expr
|
|
set foldexpr=nvim_treesitter#foldexpr()
|
|
|
|
|
|
"========================== Settings Related to SLIME ==========================
|
|
"===============================================================================
|
|
|
|
let g:slime_target = 'neovim'
|
|
let g:slime_no_mappings = 1
|
|
xmap <leader>r <Plug>SlimeRegionSend
|
|
nmap <leader>r <Plug>SlimeParagraphSend
|
|
|
|
"========================== Settings Related to IPYNB ==========================
|
|
"===============================================================================
|
|
" You have to install notedown pip3 install --user notedown.
|
|
|
|
|
|
"======================== Settings Related to Firenvim =========================
|
|
"===============================================================================
|
|
|
|
if exists('g:started_by_firenvim')
|
|
"let g:firenvim_config['.*'] = { 'takeover': 'never' }
|
|
imap <C-j> <C-n>
|
|
set fileformat=dos
|
|
colorscheme morning
|
|
set guifont=:h9
|
|
endif
|
|
|
|
|
|
"============================= Statusline Settings =============================
|
|
"===============================================================================
|
|
|
|
set statusline=
|
|
set statusline+=%-20f\ %m%-y%-r%w%<
|
|
set statusline+=%=
|
|
set statusline+=%-30.50{MyLspStatus()}
|
|
set statusline+=r:%-5l\ c:%-4v
|
|
set laststatus=2
|
|
|
|
|
|
"========================= Settings Related to GIT GUD =========================
|
|
"===============================================================================
|
|
|
|
set updatetime=200
|
|
|
|
|
|
|
|
"================== Settings related to NVim-Tree.lua ==========================
|
|
"===============================================================================
|
|
|
|
lua <<EOF
|
|
require'nvim-tree'.setup { -- BEGIN_DEFAULT_OPTS
|
|
--auto_close = false,
|
|
auto_reload_on_write = true,
|
|
disable_netrw = false,
|
|
--hide_root_folder = false,
|
|
hijack_cursor = false,
|
|
hijack_netrw = true,
|
|
hijack_unnamed_buffer_when_opening = false,
|
|
--ignore_buffer_on_setup = false,
|
|
--open_on_setup = false,
|
|
open_on_tab = false,
|
|
sort_by = "name",
|
|
update_cwd = false,
|
|
view = {
|
|
width = 30,
|
|
side = "left",
|
|
preserve_window_proportions = false,
|
|
number = false,
|
|
relativenumber = false,
|
|
signcolumn = "yes",
|
|
},
|
|
hijack_directories = {
|
|
enable = true,
|
|
auto_open = true,
|
|
},
|
|
update_focused_file = {
|
|
enable = false,
|
|
update_cwd = false,
|
|
ignore_list = {},
|
|
},
|
|
--ignore_ft_on_setup = {},
|
|
system_open = {
|
|
cmd = nil,
|
|
args = {},
|
|
},
|
|
diagnostics = {
|
|
enable = false,
|
|
show_on_dirs = false,
|
|
icons = {
|
|
hint = "",
|
|
info = "",
|
|
warning = "",
|
|
error = "",
|
|
},
|
|
},
|
|
filters = {
|
|
dotfiles = false,
|
|
custom = {},
|
|
exclude = {},
|
|
},
|
|
git = {
|
|
enable = true,
|
|
ignore = true,
|
|
timeout = 400,
|
|
},
|
|
actions = {
|
|
change_dir = {
|
|
enable = true,
|
|
global = false,
|
|
},
|
|
open_file = {
|
|
quit_on_open = false,
|
|
resize_window = false,
|
|
window_picker = {
|
|
enable = true,
|
|
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
|
|
exclude = {
|
|
filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" },
|
|
buftype = { "nofile", "terminal", "help" },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
trash = {
|
|
cmd = "trash",
|
|
require_confirm = true,
|
|
},
|
|
log = {
|
|
enable = false,
|
|
truncate = false,
|
|
types = {
|
|
all = false,
|
|
config = false,
|
|
git = false,
|
|
},
|
|
},
|
|
} -- END_DEFAULT_OPTS
|
|
EOF
|