nvim: switched to init.lua

master
tiyn 2 years ago
parent 6563c11338
commit 0cc7b1ad90

@ -0,0 +1,74 @@
vim.o.go = 'a'
vim.o.showmode = false
-- enable mouse for all modes
vim.o.mouse = 'a'
vim.o.clipboard = 'unnamedplus'
-- setting Tab-length
vim.o.expandtab = true
vim.o.softtabstop = 4
vim.o.shiftwidth = 4
-- splits open at the bottom and right
vim.o.splitbelow = true
vim.o.splitright = true
-- disable case sensitive matching
vim.o.ignorecase = true
-- enable nocompatible mode
vim.o.nocompatible = true
-- enable syntax highlighting
vim.o.syntax = true
-- enable true colors
vim.o.termguicolors = true
-- set utf-8 encoding
vim.o.encoding = "utf-8"
-- show relative numbers on left side
vim.o.number = true
vim.o.relativenumber = true
-- speedup vim with long lines
vim.o.ttyfast = true
vim.o.lazyredraw = true
-- textEdit might fail without hidden
vim.o.hidden = true
-- disable Backupfiles for Lsp
vim.o.nobackup = true
vim.o.nowritebackup = true
-- always show the signcolumn
vim.o.signcolumn = "yes"
-- enable persistent undo
vim.o.undofile = true
vim.o.undodir = vim.env.XDG_CACHE_HOME .. "/vim/undo"
-- delete trailing whitespaces on save
vim.api.nvim_create_autocmd({'BufWritePre'},
{pattern = {'*'},
command = [[%s/\s\+$//e]],
})
-- python programs to use
vim.g.python_host_prog = '/usr/bin/python2'
vim.g.python3_host_prog = '/usr/bin/python3'
-- load filetype specific mappings and commands
require('filetype')
-- load general mapped keys
require('keymap')
-- load general colorscheme
require('colorscheme')
-- load plugins (autoload all files in plugin folder)
require('loadplugins')

@ -1,457 +0,0 @@
let mapleader =","
""" Begin Plugin section
if ! filereadable(expand('~/.config/nvim/autoload/plug.vim'))
echo "Downloading junegunn/vim-plug to manage plugins..."
silent !mkdir -p ~/.config/nvim/autoload/
silent !curl "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > ~/.config/nvim/autoload/plug.vim
autocmd VimEnter * PlugInstall
endif
call plug#begin('~/.local/share/nvim/plugged')
Plug 'airblade/vim-gitgutter' " git upgrades
Plug 'alvan/vim-closetag' " auto close HTML tags
Plug 'donRaphaco/neotex' , {'for': 'tex'} " asynchronous pdf rendering for pdf
Plug 'fatih/vim-go' , {'for': 'go'} " better support for golang
Plug 'godlygeek/tabular', {'for': 'md'} " needed for preservim/vim-markdown
Plug 'hrsh7th/cmp-buffer' " autocompletion bridge for buffer
Plug 'hrsh7th/cmp-path' " autocompletion bridge for filesystem
Plug 'hrsh7th/nvim-cmp' " autocompletion
Plug 'hrsh7th/cmp-nvim-lsp' " autocompletion bridge to lsp
Plug 'itchyny/lightline.vim' " fancy statusline
Plug 'junegunn/fzf.vim' " quickly jump files using fzf
Plug 'l3mon4d3/luasnip' " snippet support
Plug 'luochen1990/rainbow' " colorized matching brackets
Plug 'majutsushi/tagbar', {'on': 'TagbarToggle'} " show tags
Plug 'mattesgroeger/vim-bookmarks' " Set bookmarks
Plug 'neovim/nvim-lspconfig' " Language server client
Plug 'onsails/lspkind-nvim' " icons on completion
Plug 'preservim/vim-markdown', {'for': 'md'} " markdown enhancements
Plug 'qpkorr/vim-renamer' " bulk renamer
Plug 'raimondi/delimitmate' " automatic closing of brackets
Plug 'rrethy/vim-hexokinase' , {'do': 'make hexokinase'} " color Preview
Plug 'ryanoasis/vim-devicons' " enable icons for vim
Plug 'saadparwaiz1/cmp_luasnip' " add snippets from luasnips to cmp
Plug 'scrooloose/nerdtree', {'on': 'NERDTreeToggle'} " filetree
Plug 'tiyn/vim-tccs' " custom colorscheme
Plug 'tpope/vim-fugitive' " git wrapper
Plug 'tpope/vim-surround' " help for quotes/parantheses
Plug 'uiiaoo/java-syntax.vim' , {'for': 'java'} " better syntax highlight for java than default
Plug 'zah/nim.vim' , {'for': 'nim'} " highlighting for nim
call plug#end()
" alvan/vim-closetag
let g:closetag_filenames = '*.html,*.xhtml,*.phtml'
let g:closetag_xhtml_filenames = '*.xhtml,*.jsx'
let g:closetag_filetypes = 'html,xhtml,phtml'
let g:closetag_xhtml_filetypes = 'xhtml,jsx'
let g:closetag_emptyTags_caseSensitive = 1
let g:closetag_regions = {
\ 'typescript.tsx': 'jsxRegion,tsxRegion',
\ 'javascript.jsx': 'jsxRegion',
\ }
let g:closetag_shortcut = '>'
let g:closetag_close_shortcut = '<leader>>'
" donRaphaco/neotex
let g:neotex_enabled = 2
" fatih/vim-go
let g:go_def_mapping_enabled = 0
" itchyny/lightline.vim
let g:lightline = { 'colorscheme': 'tccs'}
" junegunn/fzf.vim
let $FZF_DEFAULT_COMMAND = 'find . ~ -type f'
nmap <F4> :FZF<CR>
" luochen1990/rainbow
let g:rainbow_active = 1
let g:rainbow_conf = {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'],
\ 'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'],
\ 'guis': [''],
\ 'cterms': [''],
\ 'operators': '_,_',
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
\ 'separately': {
\ '*': {},
\ 'markdown': {
\ 'parentheses_options': 'containedin=markdownCode contained',
\ },
\ 'lisp': {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'],
\ },
\ 'haskell': {
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/\v\{\ze[^-]/ end=/}/ fold'],
\ },
\ 'vim': {
\ 'parentheses_options': 'containedin=vimFuncBody',
\ },
\ 'perl': {
\ 'syn_name_prefix': 'perlBlockFoldRainbow',
\ },
\ 'stylus': {
\ 'parentheses': ['start=/{/ end=/}/ fold contains=@colorableGroup'],
\ },
\ 'css': 0,
\ }
\}
" majutsushi/tagbar
map <F3> :TagbarToggle<CR>
" mattesgroeger/vim-bookmarks
let g:bookmark_no_default_key_mappings = 1
nmap mm <Plug>BookmarkToggle
nmap ma <Plug>BookmarkAnnotate
nmap ms <Plug>BookmarkShowAll
nmap mn <Plug>BookmarkNext
nmap mp <Plug>BookmarkPrev
nmap mc <Plug>BookmarkClear
highlight BookmarkSign ctermbg=NONE ctermfg=160
highlight BookmarkLine ctermbg=194 ctermfg=NONE
let g:bookmark_sign = 'B'
let g:bookmark_highlight_lines = 1
" hrsh7th/nvim-cmp
lua << EOF
-- Add additional capabilities supported by nvim-cmp
capabilities = require("cmp_nvim_lsp").default_capabilities()
-- Set completeopt to have a better completion experience
vim.o.completeopt = 'menuone,noselect'
-- nvim-cmp setup
local cmp = require("cmp")
local luasnip = require("luasnip")
local lspkind = require("lspkind")
cmp.setup {
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = {
['<S-Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
['<Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { "i", "s" }),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}},
sources = {
{ name = 'nvim_lsp' },
{ name = 'path' },
{ name = 'buffer' },
{ name = 'luasnip' },
},
formatting = {
format = lspkind.cmp_format({
mode = "symbol_text",
preset = "codicons",
maxwidth = 50,
menu = {
nvim_lsp = "[LSP]",
path = "[PATH]",
buffer = "[BUF]",
luasnip = "[SNIP]",
},
symbol_map = {
Text = "",
Method = "",
Function = "",
Constructor = "",
Field = "ﰠ",
Variable = "",
Class = "ﴯ",
Interface = "",
Module = "",
Property = "ﰠ",
Unit = "塞",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "פּ",
Event = "",
Operator = "",
TypeParameter = ""
},
}),
},
}
require("luasnip.loaders.from_snipmate").lazy_load()
EOF
" neovim/nvim-lspconfig
lua << EOF
local nvim_lsp = require('lspconfig')
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
-- Mappings.
local opts = { noremap=true, silent=true }
-- See `:help vim.lsp.*` for documentation on any of the below functions
buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
buf_set_keymap('n', 'gy', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
buf_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
buf_set_keymap('n', '<F5>', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
end
-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
local servers = { "pyright", "bashls", "tsserver", "texlab", "ccls", "gopls", "hls", "nimls", "marksman" }
for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup {
on_attach=on_attach,
capabilities=capabilities,
flags = {
debounce_text_changes = 150
}
}
end
require'lspconfig'.jdtls.setup{
on_attach=on_attach,
flags = {
debounce_text_changes = 150
},
cmd = { 'jdtls' }
}
EOF
" preservim/vim-markdown
let g:vim_markdown_folding_style_pythonic = 1
let g:vim_markdown_folding_disabled = 1
" rrethy/vim-hexokinase
let g:Hexokinase_refreshEvents = ['InsertLeave']
let g:Hexokinase_optInPatterns = [
\ 'full_hex',
\ 'triple_hex',
\ 'rgb',
\ 'rgba',
\ 'hsl',
\ 'hsla',
\ 'color_names'
\]
let g:Hexokinase_highlighters = ['backgroundfull']
autocmd VimEnter * HexokinaseTurnOn
" scrooloose/nerdtree
map <F2> :NERDTreeToggle<CR>
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
let g:NERDTreeWinPos = "left"
" tpope/vim-fugitive
nnoremap <leader>ga :Git add %:p<CR><CR>
nnoremap <leader>gd :Git diff<CR>
nnoremap <leader>gc :Gcommit<CR>
nnoremap <leader>go :Git checkout<Space>
nnoremap <leader>gh :diffget //3<CR>
nnoremap <leader>gr :Gread<CR>
nnoremap <leader>gu :diffget //2<CR>
nnoremap <leader>gs :G<CR>
""" end plugin section
set go=a
set noshowmode
" enable mouse for all modes
set mouse=a
set clipboard+=unnamedplus
" setting Tab-length
set expandtab
set softtabstop=4
set shiftwidth=4
" splits open at the bottom and right, which is non-retarded, unlike vim defaults.
set splitbelow splitright
" disable case sensitive matching
set ignorecase
" enable nocompatible mode
set nocompatible
" enable Plugins
filetype plugin on
" enable syntax highlighting
syntax on
" enable true colors
set termguicolors
" set utf-8 encoding
set encoding=utf-8
" show relative numbers on left side
set number relativenumber
" speedup vim with long lines
set ttyfast
set lazyredraw
" textEdit might fail without hidden
set hidden
" disable Backupfiles for Lsp
set nobackup
set nowritebackup
" always show the signcolumn, otherwise it would shift the text each time
" diagnostics appear/become resolved.
if has("patch-8.1.1564")
" Recently vim can merge signcolumn and number column into one
set signcolumn=number
else
set signcolumn=yes
endif
" enable persistent undo
if has('persistent_undo')
set undofile
set undodir=$XDG_CACHE_HOME/vim/undo
endif
" unmap unwanted commands
nnoremap <F1> <NOP>
nnoremap <F9> <NOP>
nnoremap <F10> <NOP>
nnoremap <F11> <NOP>
nnoremap <F12> <NOP>
inoremap <F2> <NOP>
inoremap <F3> <NOP>
inoremap <F4> <NOP>
inoremap <F5> <NOP>
inoremap <F6> <NOP>
inoremap <F7> <NOP>
inoremap <F8> <NOP>
inoremap <F9> <NOP>
inoremap <F10> <NOP>
inoremap <F11> <NOP>
inoremap <F12> <NOP>
" mapping Dictionaries
nnoremap <F6> :setlocal spell! spelllang=de_de<CR>
nnoremap <F7> :setlocal spell! spelllang=en_us<CR>
" compiler for languages
nnoremap <leader>c :w! \| !compiler <c-r>%<CR>
" open corresponding file (pdf/html/...)
nnoremap <leader>p :!opout <c-r>%<CR><CR>
" shortcut for split navigation
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" save file as sudo on files that require root permission
cnoremap w!! execute 'silent! write !sudo tee % >/dev/null' <bar> edit!
" alias for replacing
nnoremap <leader>ss :%s//gI<Left><Left><Left>
" delete trailing whitespaces on save
fun! TrimWhitespace()
let l:save = winsaveview()
keeppatterns %s/\s\+$//e
call winrestview(l:save)
endfun
autocmd BufWritePre * :call TrimWhitespace()
" read files correctly
autocmd BufRead,BufNewFile *.h set filetype=c
autocmd BufRead,BufNewFile *.html set filetype=html
autocmd BufRead,BufNewFile *.nim set filetype=nim
autocmd BufRead,BufNewFile *.py set filetype=python
autocmd BufRead,BufNewFile *.tex set filetype=tex
" formatting options
autocmd FileType java setlocal shiftwidth=2 softtabstop=2
autocmd FileType javascript setlocal shiftwidth=2 softtabstop=2
autocmd FileType markdown setlocal shiftwidth=2 softtabstop=2
" formatting programs
autocmd FileType c setlocal formatprg=astyle\ --mode=c\ --style=ansi
autocmd FileType c noremap <F8> gggqG
autocmd FileType html noremap <F8> :silent %!tidy -q -i --show-errors 0 <CR>
autocmd FileType java setlocal formatprg=astyle\ --indent=spaces=2\ --style=google
autocmd FileType java noremap <F8> gggqG
autocmd FileType markdown noremap <F8> :silent %!prettier --stdin-filepath % <CR>
autocmd FileType nim noremap <F8> :silent !nimpretty %<CR>
autocmd FileType python setlocal formatprg=autopep8\ -
autocmd FileType python noremap <F8> gggqG
autocmd FileType tex,latex setlocal formatprg=latexindent\ -
autocmd FileType tex,latex noremap <F8> gggqG
" cleanup certain files after leaving the editor
autocmd VimLeave *.c !cclear
autocmd VimLeave *.tex !texclear %
" highlighting break line
autocmd BufEnter,FileType c set colorcolumn=80
autocmd BufEnter,FileType java set colorcolumn=100
autocmd BufEnter,FileType markdown set colorcolumn=80
autocmd BufEnter,FileType nim set colorcolumn=80
autocmd BufEnter,FileType python set colorcolumn=80
autocmd BufEnter,FileType tex set colorcolumn=80
" conceallevel
autocmd BufEnter,FileType markdown set conceallevel=2
"" colorscheme
set background=dark
colorscheme tccs
highlight colorcolumn guibg=#772222
" python
let g:python_host_prog = "/usr/bin/python2"
let g:python3_host_prog = "/usr/bin/python3"
" irc compatibility to interactive
nnoremap <leader>is :.w >> in<cr>dd

@ -0,0 +1,6 @@
-- colorscheme
-- basic color settings
vim.o.background = 'dark'
vim.cmd('colorscheme tccs')
vim.api.nvim_set_hl(0, 'colorcolumn', {bg='#772222'})

@ -0,0 +1,138 @@
-- filetype
-- read files correctly
vim.filetype.add({
pattern = {
['.*.lua'] = 'lua',
['.*.h'] = 'c',
['.*.html'] = 'html',
['.*.nim'] = 'nim',
['.*.py'] = 'python',
['.*.tex'] = 'tex',
}})
-- formatting options
vim.api.nvim_create_autocmd({'FileType'},
{pattern = {'markdown'},
command = 'setlocal shiftwidth=2 softtabstop=2',
})
vim.api.nvim_create_autocmd({'FileType'},
{pattern = {'java'},
command = 'setlocal shiftwidth=2 softtabstop=2',
})
vim.api.nvim_create_autocmd({'FileType'},
{pattern = {'javascript'},
command = 'setlocal shiftwidth=2 softtabstop=2',
})
-- formatting programs
vim.api.nvim_create_autocmd({'FileType'},
{pattern = {'c'},
command = 'setlocal formatprg=astyle --mode=c --style=ansi',
})
vim.api.nvim_create_autocmd({'FileType'},
{pattern = {'c'},
command = 'noremap <F8> gggqG',
})
vim.api.nvim_create_autocmd({'FileType'},
{pattern = {'html'},
command = 'noremap <F8> :silent %!tidy -q -i --show-errors 0 <CR>',
})
vim.api.nvim_create_autocmd({'FileType'},
{pattern = {'java'},
command = 'setlocal formatprg=astyle --indent=spaces=2 --style=google',
})
vim.api.nvim_create_autocmd({'FileType'},
{pattern = {'java'},
command = 'noremap <F8> gggqG',
})
vim.api.nvim_create_autocmd({'FileType'},
{pattern = {'markdown'},
command = 'noremap <F8> :silent %!prettier --stdin-filepath % <CR>',
})
vim.api.nvim_create_autocmd({'FileType'},
{pattern = {'nim'},
command = 'noremap <F8> :silent !nimpretty %<CR>',
})
vim.api.nvim_create_autocmd({'FileType'},
{pattern = {'nim'},
command = 'noremap <F8> gggqG',
})
vim.api.nvim_create_autocmd({'FileType'},
{pattern = {'python'},
command = 'setlocal formatprg=autopep8 "%"',
})
vim.api.nvim_create_autocmd({'FileType'},
{pattern = {'python'},
command = 'noremap <F8> gggqG',
})
vim.api.nvim_create_autocmd({'FileType'},
{pattern = {'tex', 'latex'},
command = 'setlocal formatprg=latexindent',
})
vim.api.nvim_create_autocmd({'FileType'},
{pattern = {'tex', 'latex'},
command = 'noremap <F8> gggqG',
})
-- cleanup certain files after leaving the editor
vim.api.nvim_create_autocmd({'VimLeave'},
{pattern = {'*.c'},
command = '!cclear'
})
vim.api.nvim_create_autocmd({'VimLeave'},
{pattern = {'*.tex'},
command = '!texclear %'
})
-- highlighting break line
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
{pattern = {'c'},
command = 'set colorcolumn=80'
})
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
{pattern = {'java'},
command = 'set colorcolumn=100'
})
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
{pattern = {'markdown'},
command = 'set colorcolumn=80'
})
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
{pattern = {'nim'},
command = 'set colorcolumn=80'
})
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
{pattern = {'python'},
command = 'set colorcolumn=80'
})
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
{pattern = {'tex'},
command = 'set colorcolumn=80'
})
-- conceallevel
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
{pattern = {'markdown'},
command = 'set conceallevel=2'
})

@ -0,0 +1,79 @@
-- keymap
-- set mapleader for hotkeys
vim.g.mapleader = ","
-- shortcut for split navigation
vim.api.nvim_set_keymap('n', '<C-h>', '<C-w>h', {noremap = true})
vim.api.nvim_set_keymap('n', '<C-j>', '<C-w>j', {noremap = true})
vim.api.nvim_set_keymap('n', '<C-k>', '<C-w>k', {noremap = true})
vim.api.nvim_set_keymap('n', '<C-l>', '<C-w>l', {noremap = true})
-- unmap unwanted commands
vim.api.nvim_set_keymap('n', '<F1>', '<NOP>', {noremap = true})
vim.api.nvim_set_keymap('n', '<F4>', '<NOP>', {noremap = true})
vim.api.nvim_set_keymap('n', '<F9>', '<NOP>', {noremap = true})
vim.api.nvim_set_keymap('n', '<F10>', '<NOP>', {noremap = true})
vim.api.nvim_set_keymap('n', '<F11>', '<NOP>', {noremap = true})
vim.api.nvim_set_keymap('n', '<F12>', '<NOP>', {noremap = true})
vim.api.nvim_set_keymap('i', '<F2>', '<NOP>', {noremap = true})
vim.api.nvim_set_keymap('i', '<F3>', '<NOP>', {noremap = true})
vim.api.nvim_set_keymap('i', '<F4>', '<NOP>', {noremap = true})
vim.api.nvim_set_keymap('i', '<F5>', '<NOP>', {noremap = true})
vim.api.nvim_set_keymap('i', '<F6>', '<NOP>', {noremap = true})
vim.api.nvim_set_keymap('i', '<F7>', '<NOP>', {noremap = true})
vim.api.nvim_set_keymap('i', '<F8>', '<NOP>', {noremap = true})
vim.api.nvim_set_keymap('i', '<F9>', '<NOP>', {noremap = true})
vim.api.nvim_set_keymap('i', '<F10>', '<NOP>', {noremap = true})
vim.api.nvim_set_keymap('i', '<F11>', '<NOP>', {noremap = true})
vim.api.nvim_set_keymap('i', '<F12>', '<NOP>', {noremap = true})
-- mapping Dictionaries
vim.api.nvim_set_keymap('n', '<F6>', ':setlocal spell! spelllang=de_de<CR>', {noremap = true})
vim.api.nvim_set_keymap('n', '<F7>', ':setlocal spell! spelllang=en_us<CR>', {noremap = true})
-- compiler for languages
vim.api.nvim_set_keymap('n', '<leader>c', ':w! | !compiler <c-r>%<CR>', {noremap = true})
-- open corresponding file (pdf/html/...)
vim.api.nvim_set_keymap('n', '<leader>p', ':!opout <c-r>%<CR><CR>', {noremap = true})
-- save file as sudo on files that require root permission
vim.api.nvim_set_keymap('c', 'w!!', '"silent! write !sudo tee % >/dev/null" <bar> edit!', {noremap = true})
-- alias for replacing
vim.api.nvim_set_keymap('n', '<leader>ss', ':%s//gI<Left><Left><Left>', {noremap = true})
-- irc compatibility for interactivity
vim.api.nvim_set_keymap('n', '<leader>is', ':.w >> in<cr>dd', {noremap = true})
-- majutsushi/tagbar
vim.api.nvim_set_keymap('n', '<F3>', ':TagbarToggle<CR>', {})
-- scrooloose/nerdtree
vim.api.nvim_set_keymap('n', '<F2>', ':NERDTreeToggle<CR>', {})
-- tpope/vim-fugitive
vim.api.nvim_set_keymap('n', '<leader>ga', ':Git add %:p<CR><CR>', { noremap = true })
vim.api.nvim_set_keymap('n', '<leader>gd', ':Git diff<CR>', { noremap = true })
vim.api.nvim_set_keymap('n', '<leader>gc', ':Git commit<CR>', { noremap = true })
vim.api.nvim_set_keymap('n', '<leader>gh', ':diffget //3<CR>', { noremap = true })
vim.api.nvim_set_keymap('n', '<leader>gr', ':Gread<CR>', { noremap = true })
vim.api.nvim_set_keymap('n', '<leader>gu', ':diffget //2<CR>', { noremap = true })
vim.api.nvim_set_keymap('n', '<leader>gs', ':G<CR>', { noremap = true })
-- hrsh7th/nvim-cmp
local on_attach = function(client, bufnr)
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
local opts = { noremap=true, silent=true }
buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
buf_set_keymap('n', 'gy', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
buf_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
buf_set_keymap('n', '<F5>', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
end

@ -0,0 +1,75 @@
-- loadplugins
-- load plugins with packer
return require("packer").startup(function(use)
-- automatic closing of brackets
use 'raimondi/delimitmate'
-- improved java syntax highlighting
use {'uiiaoo/java-syntax.vim',
ft = {'java'}}
-- custom statusline
use {'itchyny/lightline.vim',
require = {"tiyn/vim-tccs"}}
-- latex asynchronous pdf rendering
use {'donRaphaco/neotex',
ft = {'tex'}}
-- navigating folders with a file tree
use {'scrooloose/nerdtree',
cmd = 'NERDTreeToggle',
requires = 'ryanoasis/vim-devicons'}
-- nim language support
use {'zah/nim.vim', ft = {'nim'}}
-- autocompletion and its sources
use {'hrsh7th/nvim-cmp',
requires = {'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path',
'hrsh7th/cmp-nvim-lsp',
'l3mon4d3/luasnip',
'saadparwaiz1/cmp_luasnip',
'neovim/nvim-lspconfig',
'onsails/lspkind-nvim'}}
-- showing color of hex values, etc
use 'norcalli/nvim-colorizer.lua'
-- package manager
use 'wbthomason/packer.nvim'
-- colorful brackets
use 'luochen1990/rainbow'
-- show tags
use {'majutsushi/tagbar',
cmd = 'TagbarToggle'}
-- git wrapper
use 'tpope/vim-fugitive'
-- indicate git diff status of line
use 'airblade/vim-gitgutter'
-- golang language support
use {'fatih/vim-go',
ft = {'go'}}
-- markdown language support
use {'preservim/vim-markdown',
ft = {'md'},
requires = {'godlygeek/tabular'}}
-- bulk renamer
use 'qpkorr/vim-renamer'
-- additional quote/parantheses funtions
use 'tpope/vim-surround'
-- colorscheme
use 'tiyn/vim-tccs'
end)

@ -0,0 +1,2 @@
-- itchyny/lightline.vim
vim.g.lightline = { colorscheme = 'tccs'}

@ -0,0 +1,2 @@
-- donRaphaco/neotex
vim.g.neotex_enabled = 2

@ -0,0 +1,2 @@
-- scrooloose/nerdtree
vim.g.NERDTreeWinPos = 'left'

@ -0,0 +1,115 @@
-- hrsh7th/nvim-cmp
-- Add additional capabilities supported by nvim-cmp
capabilities = require("cmp_nvim_lsp").default_capabilities()
-- Set completeopt to have a better completion experience
vim.o.completeopt = 'menuone,noselect'
-- nvim-cmp setup
local cmp = require("cmp")
local luasnip = require("luasnip")
local lspkind = require("lspkind")
cmp.setup {
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = {
['<S-Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
['<Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { "i", "s" }),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}},
sources = {
{ name = 'nvim_lsp' },
{ name = 'path' },
{ name = 'buffer' },
{ name = 'luasnip' },
},
formatting = {
format = lspkind.cmp_format({
mode = "symbol_text",
preset = "codicons",
maxwidth = 50,
menu = {
nvim_lsp = "[LSP]",
path = "[PATH]",
buffer = "[BUF]",
luasnip = "[SNIP]",
},
symbol_map = {
Text = "",
Method = "",
Function = "",
Constructor = "",
Field = "",
Variable = "",
Class = "",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = ""
},
}),
},
}
require("luasnip.loaders.from_snipmate").lazy_load()
-- neovim/nvim-lspconfig
local nvim_lsp = require('lspconfig')
-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
local servers = { "pyright", "bashls", "tsserver", "texlab", "ccls", "gopls", "hls", "nimls", "marksman" }
for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup {
on_attach=on_attach,
capabilities=capabilities,
flags = {
debounce_text_changes = 150
}
}
end
require'lspconfig'.jdtls.setup{
on_attach=on_attach,
flags = {
debounce_text_changes = 150
},
cmd = { 'jdtls' }
}

@ -0,0 +1,2 @@
-- norcalli/nvim-colorizer.lua
require 'colorizer'.setup()

@ -0,0 +1,2 @@
-- luochen1990/rainbow
vim.g.rainbow_active = 1

@ -0,0 +1,2 @@
-- fatih/vim-go
vim.g.go_def_mapping_enabled = 0

@ -0,0 +1,3 @@
-- preservim/vim-markdown
vim.g.vim_markdown_folding_style_pythonic = 1
vim.g.vim_markdown_folding_disabled = 1
Loading…
Cancel
Save