2021-02-25 19:14:33 +00:00
|
|
|
"===============================================================================
|
|
|
|
"====================== 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=
|
|
|
|
|
2021-03-01 13:55:18 +00:00
|
|
|
" Use a different mapleader.
|
|
|
|
let mapleader='°'
|
|
|
|
|
2021-02-25 19:14:33 +00:00
|
|
|
" 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>
|
2021-02-26 13:15:39 +00:00
|
|
|
" I disabled this, since the shell requires arrow keys...
|
|
|
|
"tnoremap <Up> <Nop>
|
|
|
|
"tnoremap <Down> <Nop>
|
|
|
|
"tnoremap <Left> <Nop>
|
|
|
|
"tnoremap <Right> <Nop>
|
2021-02-25 19:14:33 +00:00
|
|
|
|
|
|
|
" 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
|
|
|
|
|
2021-03-01 13:55:18 +00:00
|
|
|
" I user :terminal quite often.
|
|
|
|
nnoremap <leader>t :sp<Cr>:terminal<Cr>a
|
|
|
|
|
2021-02-25 19:14:33 +00:00
|
|
|
"====================== 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
|
|
|
|
|
|
|
|
|
|
|
|
"_______________________________________________________________________________
|
|
|
|
"========================= 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/completion-nvim'
|
2021-03-14 21:11:19 +00:00
|
|
|
Plug 'nvim-lua/lsp-status.nvim'
|
2021-02-25 19:14:33 +00:00
|
|
|
|
|
|
|
" Inserting unicode characters.
|
|
|
|
Plug 'chrisbra/unicode.vim'
|
|
|
|
|
|
|
|
" Color schemes.
|
|
|
|
Plug 'tomasr/molokai'
|
|
|
|
Plug 'bluz71/vim-moonfly-colors'
|
2021-02-28 10:21:32 +00:00
|
|
|
Plug 'bluz71/vim-nightfly-guicolors'
|
|
|
|
Plug 'sainnhe/sonokai'
|
2021-02-28 19:23:42 +00:00
|
|
|
Plug 'dylnmc/vulpo.vim'
|
2021-02-25 19:14:33 +00:00
|
|
|
|
|
|
|
" This is for snippets.
|
|
|
|
Plug 'SirVer/ultisnips'
|
|
|
|
|
2021-02-28 10:21:32 +00:00
|
|
|
" Treesitter seems to be a reall nice
|
|
|
|
" plugin for code highlighting.
|
|
|
|
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
|
|
|
|
|
2021-03-01 13:55:18 +00:00
|
|
|
" 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) } }
|
2021-03-14 21:11:19 +00:00
|
|
|
|
|
|
|
" This is a tree manager
|
|
|
|
Plug 'kyazdani42/nvim-web-devicons'
|
|
|
|
Plug 'kyazdani42/nvim-tree.lua'
|
2021-03-14 21:26:17 +00:00
|
|
|
|
|
|
|
" Git Gut.
|
|
|
|
Plug 'airblade/vim-gitgutter'
|
2021-02-25 19:14:33 +00:00
|
|
|
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
|
|
|
|
|
2021-03-14 21:11:19 +00:00
|
|
|
local nvim_lsp_status = require('lsp-status')
|
|
|
|
nvim_lsp_status.register_progress()
|
2021-02-25 19:14:33 +00:00
|
|
|
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()
|
2021-03-14 21:11:19 +00:00
|
|
|
-- also attach lsp-status
|
|
|
|
nvim_lsp_status.on_attach(_, bufnr)
|
2021-02-25 19:14:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Enable the language servers.
|
2021-03-14 21:11:19 +00:00
|
|
|
nvim_lsp.ccls.setup{on_attach=on_attach, capabilities=nvim_lsp_status.capabilities}
|
|
|
|
nvim_lsp.vimls.setup{on_attach=on_attach, capabilities=nvim_lsp_status.capabilities}
|
|
|
|
nvim_lsp.pyls.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}
|
2021-02-25 19:14:33 +00:00
|
|
|
|
|
|
|
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> gh <cmd>lua vim.lsp.buf.hover()<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,
|
|
|
|
-- This sets the spacing and the prefix, obviously.
|
|
|
|
virtual_text = {
|
|
|
|
spacing = 4
|
|
|
|
, prefix = '🔙'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
EOF
|
2021-03-14 21:11:19 +00:00
|
|
|
" Statusline
|
|
|
|
function! LspStatus() abort
|
|
|
|
if luaeval('#vim.lsp.buf_get_clients() > 0')
|
|
|
|
return luaeval("require('lsp-status').status()")
|
|
|
|
endif
|
|
|
|
|
|
|
|
return ''
|
|
|
|
endfunction
|
2021-02-25 19:14:33 +00:00
|
|
|
|
|
|
|
"========================= Settings For Autocompletion =========================
|
|
|
|
"===============================================================================
|
|
|
|
|
|
|
|
" This prevents vim from inserting random function heads,
|
|
|
|
" and also gives some documentation preview.
|
|
|
|
set completeopt=menuone,noinsert,noselect
|
|
|
|
|
|
|
|
" This prevents the auto-completion from
|
|
|
|
" inserting the full method signature.
|
|
|
|
let g:completion_enable_auto_signature = 0
|
|
|
|
|
|
|
|
let g:completion_enable_snippet = 'UltiSnips'
|
2021-02-27 18:09:22 +00:00
|
|
|
" Use completion-nvim in every buffer
|
|
|
|
autocmd BufEnter * lua require'completion'.on_attach()
|
2021-02-25 19:14:33 +00:00
|
|
|
|
2021-02-28 10:21:32 +00:00
|
|
|
" This function and mapping is basically related
|
|
|
|
" to autocompletion as well.
|
|
|
|
" It automatically maps a single bracket to the
|
|
|
|
" GNU-style formatted bracket.
|
|
|
|
let g:AutoInsertBracket_enable = 0
|
|
|
|
|
|
|
|
function! AutoInsertBracket()
|
|
|
|
if g:AutoInsertBracket_enable
|
|
|
|
return "{\n}\<Esc>O"
|
|
|
|
else
|
|
|
|
return "{"
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
inoremap <expr> { AutoInsertBracket()
|
|
|
|
|
|
|
|
|
2021-02-25 19:14:33 +00:00
|
|
|
|
|
|
|
"========================== A Nice Color Scheme ================================
|
|
|
|
"===============================================================================
|
|
|
|
|
|
|
|
"set background=dark
|
|
|
|
"let g:airline_theme='one'
|
|
|
|
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
|
|
|
|
set termguicolors
|
2021-02-28 10:21:32 +00:00
|
|
|
" 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
|
2021-02-25 19:14:33 +00:00
|
|
|
colorscheme molokai
|
|
|
|
|
|
|
|
"=================== Settings Related to Highlighting ==========================
|
|
|
|
"===============================================================================
|
|
|
|
|
2021-03-01 13:55:18 +00:00
|
|
|
let g:vimsyn_embed = 'l'
|
2021-02-28 10:21:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
"==================== Settings Related to Treesitter ===========================
|
|
|
|
"===============================================================================
|
|
|
|
|
|
|
|
" Install the language parsers.
|
|
|
|
"TSInstall python
|
|
|
|
"TSInstall c
|
|
|
|
"TSInstall cpp
|
|
|
|
"TSInstall bash
|
2021-03-01 13:55:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"========================= 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')
|
|
|
|
imap <C-j> <C-n>
|
|
|
|
set fileformat=dos
|
2021-03-13 09:33:41 +00:00
|
|
|
colorscheme morning
|
|
|
|
set guifont=:h9
|
2021-03-01 13:55:18 +00:00
|
|
|
endif
|
2021-03-14 21:11:19 +00:00
|
|
|
|
|
|
|
|
2021-03-14 21:26:17 +00:00
|
|
|
"========================== Statusline Settings ================================
|
2021-03-14 21:11:19 +00:00
|
|
|
"===============================================================================
|
|
|
|
|
|
|
|
set statusline=
|
|
|
|
set statusline+=%-f\ %-y%-r%<
|
|
|
|
set statusline+=%=%-0.20{LspStatus()}
|
|
|
|
set statusline+=%=%l,%v
|
|
|
|
set laststatus=2
|
2021-03-14 21:26:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
"===================== Settings Related to GIT GUD =============================
|
|
|
|
"===============================================================================
|
|
|
|
|
|
|
|
set updatetime=200
|