Refactor neovim config (#2)

Changes include:

- [x] Use init.lua instead of init.vim
   - Some keybindings are still to be converted
- [x] Use packer as a package manager instead of vim-plug
- [ ] Use built-in lsp instead of coc.nvim
   - [x] Set up language servers
   - [x] Completion
   - [x] Formatting (previously coc-prettier, now neoformat)
   - [ ] Snippets
- [ ] Replace fzf with telescope.nvim
- [x] Implement treesitter syntax highlighting
   - More info: https://github.com/nvim-treesitter/nvim-treesitter

Note that this requires neovim nightly until 0.5 is released

Reviewed-on: #2
Co-authored-by: Marko Korhonen <marko@korhonen.cc>
Co-committed-by: Marko Korhonen <marko@korhonen.cc>
This commit is contained in:
Marko Korhonen 2021-08-08 15:33:23 +03:00
parent 80c6f3c9c3
commit c024a40316
24 changed files with 492 additions and 525 deletions

View file

@ -1,5 +1,5 @@
actions:
vim-plug: nvim +PlugInstall +qall
nvim-packer-install: nvim +PackerInstall
config:
backup: true
banner: true
@ -25,20 +25,20 @@ dotfiles:
d_imapnotify:
dst: ~/.config/imapnotify
src: .config/imapnotify
f_init.vim:
dst: ~/.config/nvim/init.vim
src: .config/nvim/init.vim
d_nvim_config:
f_nvim_init:
dst: ~/.config/nvim/init.lua
src: .config/nvim/init.lua
d_nvim_lua:
actions:
- vim-plug
dst: ~/.config/nvim/conf.d
src: .config/nvim/conf.d
- nvim-packer-install
dst: ~/.config/nvim/lua
src: .config/nvim/lua
d_nvim_scripts:
dst: ~/.config/nvim/scripts
src: .config/nvim/scripts
f_user-dirs.dirs:
dst: ~/.config/user-dirs.dirs
src: .config/user-dirs.dirs
f_coc-settings.json:
dst: ~/.config/nvim/coc-settings.json
src: .config/nvim/coc-settings.json
d_sway:
dst: ~/.config/sway
src: .config/sway
@ -165,107 +165,107 @@ dotfiles:
f_gpg-agent.conf:
src: .gnupg/gpg-agent.conf
dst: ~/.gnupg/gpg-agent.conf
chmod: '600'
chmod: "600"
f_gpg.conf:
src: .gnupg/gpg.conf
dst: ~/.gnupg/gpg.conf
profiles:
base:
dotfiles:
- d_systemd
- d_systemd
terminal:
dotfiles:
- f_nvimpager
- f_hushlogin
- f_ripgrep_ignore
- f_ranger_commands.py
- f_rtv.cfg
- f_mailcap
- d_zsh
- f_zshrc
- f_tmux.conf
- f_ranger.conf
- f_ssh.conf
- f_authorized_keys
- d_nvim_config
- f_init.vim
- f_coc-settings.json
- f_gitconfig
- f_alacritty.yml
- f_nvimpager
- f_hushlogin
- f_ripgrep_ignore
- f_ranger_commands.py
- f_rtv.cfg
- f_mailcap
- d_zsh
- f_zshrc
- f_tmux.conf
- f_ranger.conf
- f_ssh.conf
- f_authorized_keys
- d_nvim_lua
- d_nvim_scripts
- f_nvim_init
- f_gitconfig
- f_alacritty.yml
email:
dotfiles:
- d_neomutt
- d_imapnotify
- f_mbsyncrc
- f_msmtp_config
- d_neomutt
- d_imapnotify
- f_mbsyncrc
- f_msmtp_config
media:
dotfiles:
- f_beets_config
- f_beets_whitelist
- f_abcde.conf
- d_mpv
- f_youtube-dl_config
- f_mpd.conf
- f_ncmpcpp_bindings
- f_ncmpcpp.conf
- f_libra_config
- f_mpdscribble.conf
- f_mpdris2.conf
- f_beets_config
- f_beets_whitelist
- f_abcde.conf
- d_mpv
- f_youtube-dl_config
- f_mpd.conf
- f_ncmpcpp_bindings
- f_ncmpcpp.conf
- f_libra_config
- f_mpdscribble.conf
- f_mpdris2.conf
sway:
dotfiles:
- d_sway
- d_waybar
- d_wofi
- f_mako_config
- f_redshift.conf
- f_zathurarc
- f_mimeo_associations.txt
- f_tdesktop_lang.strings
- f_fonts.conf
- f_zprofile
- d_sway
- d_waybar
- d_wofi
- f_mako_config
- f_redshift.conf
- f_zathurarc
- f_mimeo_associations.txt
- f_tdesktop_lang.strings
- f_fonts.conf
- f_zprofile
Pacman:
dotfiles:
- f_makepkg.conf
- f_paru.conf
- f_makepkg.conf
- f_paru.conf
Mirkwood:
include:
- base
- terminal
- email
- media
- sway
- Pacman
- base
- terminal
- email
- media
- sway
- Pacman
dotfiles:
- f_paru.conf
- f_user-dirs.dirs
- f_gitconfig
- f_foot.ini
- f_gpg-agent.conf
- f_gpg.conf
- f_paru.conf
- f_user-dirs.dirs
- f_gitconfig
- f_foot.ini
- f_gpg-agent.conf
- f_gpg.conf
Moria:
include:
- terminal
- media
- Pacman
- terminal
- media
- Pacman
Gondor:
include:
- terminal
- Pacman
- terminal
- Pacman
mko-laptop:
include:
- terminal
- media
- terminal
- media
Edoras:
include:
- terminal
- Pacman
- terminal
- Pacman
TakamakiPC:
include:
- terminal
- Pacman
- terminal
- Pacman
localhost:
include:
- terminal
- terminal
ViiruJaTeippi:
include:
- terminal
- terminal

View file

@ -1,33 +0,0 @@
{
"python.jediEnabled": false,
"suggest.noselect": false,
"suggest.echodocSupport": true,
"suggest.maxCompleteItemCount": 20,
"coc.preferences.formatOnSaveFiletypes": [],
"prettier.singleQuote": false,
"diagnostic.errorSign": "•",
"diagnostic.warningSign": "•",
"diagnostic.infoSign": "•",
"suggest.snippetIndicator": "~",
"rust-analyzer.serverPath": "/usr/bin/rust-analyzer",
"languageserver": {
"bash": {
"command": "bash-language-server",
"args": ["start"],
"filetypes": ["sh"],
"ignoredRootPaths": ["~"]
},
"xml": {
"command": "xml-language-server",
"args": ["start"],
"filetypes": ["xml"],
"ignoredRootPaths": ["~"]
}
},
"markdownlint.config": {
"rules": {
"default": true,
"line_length": false
}
}
}

View file

@ -1,96 +0,0 @@
" Auto-install vim-plug
if empty(glob('~/.config/nvim/autoload/plug.vim'))
silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall
endif
" Set coc extensions
let g:coc_global_extensions = [
\ 'coc-tsserver',
\ 'coc-html',
\ 'coc-tsserver',
\ 'coc-json',
\ 'coc-yaml',
\ 'coc-texlab',
\ 'coc-prettier',
\ 'coc-python',
\ 'coc-emmet',
\ 'coc-rust-analyzer',
\ 'coc-markdownlint',
\ 'coc-snippets',
\ 'coc-java',
\ 'coc-flutter'
\ ]
call plug#begin()
" statusline/tabline
Plug 'vim-airline/vim-airline'
" Make editing passwords safer
Plug 'https://git.zx2c4.com/password-store', { 'rtp': 'contrib/vim/redact_pass.vim' }
" Colorize color words
Plug 'norcalli/nvim-colorizer.lua'
" NeoVim in Firefox
Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } }
" Spelling
Plug 'vim-scripts/Vimchant'
" Pandoc plugins
Plug 'vim-pandoc/vim-pandoc'
Plug 'conornewton/vim-pandoc-markdown-preview'
" Fuzzy finder
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
" Language syntax pack
Plug 'sheerun/vim-polyglot'
" Read editorconfig settings
Plug 'editorconfig/editorconfig-vim'
" Make directory if it doesn't exist
Plug 'pbrisbin/vim-mkdir'
" Tree explorer
Plug 'scrooloose/nerdtree'
" Moar snippets
Plug 'honza/vim-snippets'
" Filetype icons
Plug 'ryanoasis/vim-devicons'
" Surround stuff with brackets and quotes
Plug 'tpope/vim-surround'
" Do stuff as sudo
Plug 'lambdalisue/suda.vim'
" Conguer of Completion
Plug 'neoclide/coc.nvim', {'do': './install.sh nightly'}
" VimL source for CoC
Plug 'Shougo/neco-vim'
Plug 'neoclide/coc-neco'
" Git plugin
Plug 'jreybert/vimagit'
" Git diff in gutter
Plug 'airblade/vim-gitgutter'
" Gpg support
Plug 'jamessan/vim-gnupg'
" Colorscheme
Plug 'joshdick/onedark.vim'
" Latex plugin
Plug 'lervag/vimtex'
call plug#end()

View file

@ -1,46 +0,0 @@
" Set colorscheme
colorscheme onedark
" Floating window transparency
set winblend=10
" Enable italics
let g:onedark_terminal_italics=1
" Disable built-in statusline because airline shows it
set noshowmode
" Airline
set laststatus=2
set encoding=utf-8
let g:airline#extensions#tabline#enabled = 1
let g:airline_powerline_fonts = 1
let g:airline_section_warning = ''
let g:airline_section_error = ''
let g:airline_theme='onedark'
" True color support
set termguicolors
" Line numbering
set relativenumber
set number
" Always show signcolumn
set signcolumn=yes
" Autoindent and syntax highlight
set autoindent
set smartindent
syntax on
filetype on
filetype plugin indent on
set tabstop=4
set shiftwidth=4
" Make gutter and cursorline bg transparent
highlight CursorLineNr guibg=transparent
highlight SignColumn guibg=transparent
" Don't wrap in the middle of words
set linebreak

View file

@ -1,39 +0,0 @@
" Change leader to space
nnoremap <SPACE> <Nop>
let mapleader = ' '
" Toggle nerdtree
map <silent> <C-t> :NERDTreeToggle<CR>
" Markdown preview
nmap <C-s> <Plug>MarkdownPreview
nmap <M-s> <Plug>MarkdownPreviewStop
nmap <C-p> <Plug>MarkdownPreviewToggle
set splitbelow
set splitright
" Move between buffers
nnoremap <C-N> :bn<CR>
nnoremap <C-B> :bp<CR>
" Move between splits
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>
" Enable mouse
set mouse=a
" Toggle equalalways
function ToggleEqual ()
:set equalalways!
:set equalalways!
endfunction
nnoremap <leader>= :call ToggleEqual()<CR>
" Navigate display lines insted of physical lines
nnoremap j gj
nnoremap k gk

View file

@ -1,129 +0,0 @@
" Enable symbol highlight
autocmd CursorHold * silent call CocActionAsync('highlight')
" If hidden is not set, TextEdit might fail.
set hidden
" Some servers have issues with backup files, see #649
set nobackup
set nowritebackup
" Better display for messages
set cmdheight=2
" Smaller updatetime for CursorHold & CursorHoldI
set updatetime=300
" Don't give |ins-completion-menu| messages.
set shortmess+=c
" Use tab for trigger completion with characters ahead and navigate.
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <cr> to confirm snippet
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm() :
\"\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
" Use <c-space> to trigger completion.
inoremap <silent><expr> <c-space> coc#refresh()
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
" Coc only does snippet and additional edit on confirm.
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" Use `[c` and `]c` to navigate diagnostics
nmap <silent> [c <Plug>(coc-diagnostic-prev)
nmap <silent> ]c <Plug>(coc-diagnostic-next)
" Remap keys for gotos
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Use K to show documentation in preview window
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" Highlight symbol under cursor on CursorHold
autocmd CursorHold * silent call CocActionAsync('highlight')
" Remap for rename current word
nmap <leader>rn <Plug>(coc-rename)
" Remap for format selected region
xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
augroup mygroup
autocmd!
" Setup formatexpr specified filetype(s).
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" Update signature help on jump placeholder
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
" Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
" Remap for do codeAction of current line
nmap <leader>ac <Plug>(coc-codeaction)
" Fix autofix problem of current line
nmap <leader>qf <Plug>(coc-fix-current)
" Use `:Format` to format current buffer
command! -nargs=0 Format :call CocAction('format')
" Use `:Fold` to fold current buffer
command! -nargs=? Fold :call CocAction('fold', <f-args>)
" Add diagnostic info for https://github.com/itchyny/lightline.vim
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'cocstatus', 'readonly', 'filename', 'modified' ] ]
\ },
\ 'component_function': {
\ 'cocstatus': 'coc#status'
\ },
\ }
" Using CocList
" Show all diagnostics
nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
" Manage extensions
nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
" Show commands
nnoremap <silent> <space>c :<C-u>CocList commands<cr>
" Find symbol of current document
nnoremap <silent> <space>o :<C-u>CocList outline<cr>
" Search workspace symbols
nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <silent> <space>j :<C-u>CocNext<CR>
" Do default action for previous item.
nnoremap <silent> <space>k :<C-u>CocPrev<CR>
" Resume latest coc list
nnoremap <silent> <space>p :<C-u>CocListResume<CR>

View file

@ -1,12 +0,0 @@
" LaTex settings
let g:vimtex_view_method='zathura'
let g:Tex_DefaultTargetFormat='pdf'
let g:Tex_MultipleCompileFormats='pdf, aux'
let g:vimtex_compiler_progname='nvr'
" YAML settings
au! BufNewFile,BufReadPost *.{yaml,yml} set filetype=yaml foldmethod=indent
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
" Run rustfmt on save
let g:rustfmt_autosave = 1

View file

@ -1,41 +0,0 @@
" Enable python support
let g:python3_host_prog='/usr/bin/python3'
let pyxversion=3
" LaTex fallback flavor
let g:tex_flavor = 'latex'
" Use suda by default
let g:suda_smart_edit = 1
" Remap exit terminal mode to esc
au TermOpen * tnoremap <buffer> <Esc> <c-\><c-n>
" Use system clipboard
set clipboard=unnamedplus
" Remove extra line
set cmdheight=1
" Disable auto commenting
set formatoptions-=cro
" Set pandoc preview program
let g:pandoc_preview_pdf_cmd = "zathura"
" Case insensitive search
set ignorecase
set smartcase
" Nerdtree settings
let NERDTreeMinimalUI = 1 "remove press ? for help"
let NERDTreeAutoDeleteBuffer = 1 " delete buffer when file is deleted
let NERDTreeQuitOnOpen = 1 " close nerdtree when opening file
let NERDTreeDirArrows = 1
" Firenvim filetypes
au BufEnter github.com_*.txt set filetype=markdown
au BufEnter gitlab.com_*.txt set filetype=markdown
au BufEnter git.reekynet.com_*.txt set filetype=markdown
au BufEnter www.reddit.com_*.txt set filetype=markdown
au BufEnter node.reekynet.com_*.txt set filetype=json

View file

@ -1,43 +0,0 @@
" FZF in floating window
autocmd! FileType fzf
autocmd FileType fzf call SetFZFoptions()
function SetFZFoptions()
set noshowmode noruler nonumber norelativenumber
tunmap <buffer> <Esc>
endfunction
let g:fzf_layout = { 'window': 'call FloatingFZF()' }
function! FloatingFZF()
let buf = nvim_create_buf(v:false, v:true)
call setbufvar(buf, '&signcolumn', 'no')
let width = float2nr(&columns * 0.8)
let height = float2nr(&lines * 0.6)
let horizontal = 1
let vertical = 1
let opts = {
\ 'relative': 'editor',
\ 'row': (&lines - height) / 2,
\ 'col': (&columns - width) / 2,
\ 'width': width,
\ 'height': height,
\ 'style': 'minimal'
\ }
call nvim_open_win(buf, v:true, opts)
endfunction
" Looks
"let $FZF_DEFAULT_OPTS=' --color=dark --color=fg:15,bg:-1,hl:1,fg+:#ffffff,bg+:0,hl+:1 --color=info:0,prompt:0,pointer:12,marker:4,spinner:11,header:-1 --layout=reverse --margin=1,4'
" ripgrep custom settings
command! -bang -nargs=* Rg
\ call fzf#vim#grep('rg --column --line-number --no-heading --color=always --smart-case '
\ . (len(<q-args>) > 0 ? <q-args> : '""'), 0,
\ fzf#vim#with_preview({'options': ['--delimiter=:', '--nth=2..', '--layout=reverse', '--info=inline']}), <bang>0)
" Keybinds
nmap <C-f> :Files<CR>
nmap <C-g> :Rg<CR>

View file

@ -0,0 +1,13 @@
require 'pluginmanager'
require 'autocmd'
require 'keybinds'
require 'settings'
-- Plugin configurations
require 'pluginconf.lualine'
require 'pluginconf.bufferline'
require 'pluginconf.completion'
require 'pluginconf.lsp'
require 'pluginconf.treesitter'
require 'pluginconf.telescope'
-- require 'pluginconf.indent-blankline'

View file

@ -1,3 +0,0 @@
for f in split(glob('~/.config/nvim/conf.d/*.vim'), '\n')
exe 'source' f
endfor

View file

@ -0,0 +1,7 @@
local cmd = vim.cmd
-- Remap exit terminal mode to esc
cmd('au TermOpen * tnoremap <buffer> <Esc> <c-\\><c-n>')
-- Fix YAML indentation
cmd('au FileType yaml setlocal ts=2 sts=2 sw=2 expandtab')

View file

@ -0,0 +1,27 @@
local function map(mode, lhs, rhs, opts)
local options = {noremap = true}
if opts then options = vim.tbl_extend('force', options, opts) end
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
end
-- Open/close tree browser
map('n', '<C-Tab>', '<cmd>NvimTreeToggle<CR>')
-- Telescope
map('n', '<C-f>', '<cmd>Telescope find_files find_command=fd,-Ht,f<CR>')
map('n', '<C-g>', '<cmd>Telescope live_grep<CR>')
-- Completion
-- Navigate completions with tab and shift tab
map('i', '<S-Tab>', 'pumvisible() ? "\\<C-p>" : "\\<Tab>"', {expr = true})
map('i', '<Tab>', 'pumvisible() ? "\\<C-n>" : "\\<Tab>"', {expr = true})
-- Navigate between buffers
map('n', '<C-N>', ':bn<CR>', {silent = true})
map('n', '<C-B>', ':bp<CR>', {silent = true})
-- Navigate between splits
map('n', '<C-H>', '<C-W><C-H>')
map('n', '<C-J>', '<C-W><C-J>')
map('n', '<C-K>', '<C-W><C-K>')
map('n', '<C-L>', '<C-W><C-L>')

View file

@ -0,0 +1 @@
require("bufferline").setup{}

View file

@ -0,0 +1,4 @@
vim.o.completeopt = 'menuone,noinsert,noselect'
-- Enable for all buffers (for now)
vim.api.nvim_command('autocmd BufEnter * lua require\'completion\'.on_attach()')

View file

@ -0,0 +1 @@
require('indent_blankline').setup {filetype_exclude = {'help'}}

View file

@ -0,0 +1,143 @@
-- List of servers to install
local required_servers = {
"css", "html", "java", "json", "lua", "rust", "yaml", "dockerfile", "latex",
"bash", "typescript", "php"
}
-- keymaps
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
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
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', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>',
opts)
buf_set_keymap('n', '<space>wa',
'<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<space>wr',
'<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<space>wl',
'<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>',
opts)
buf_set_keymap('n', '<space>D',
'<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
buf_set_keymap('n', '<space>e',
'<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>',
opts)
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>',
opts)
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>',
opts)
buf_set_keymap('n', '<space>q',
'<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
-- Set some keybinds conditional on server capabilities
if client.resolved_capabilities.document_formatting then
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting()<CR>",
opts)
elseif client.resolved_capabilities.document_range_formatting then
buf_set_keymap("n", "<space>f",
"<cmd>lua vim.lsp.buf.range_formatting()<CR>", opts)
end
-- Set autocommands conditional on server_capabilities
if client.resolved_capabilities.document_highlight then
vim.api.nvim_exec([[
augroup lsp_document_highlight
autocmd! * <buffer>
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
augroup END
]], false)
end
end
-- Configure lua language server for neovim development
local lua_settings = {
Lua = {
runtime = {
-- LuaJIT in the case of Neovim
version = 'LuaJIT',
path = vim.split(package.path, ';')
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = {'vim'}
},
workspace = {
-- Make the server aware of Neovim runtime files
library = {
[vim.fn.expand('$VIMRUNTIME/lua')] = true,
[vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true
}
}
}
}
-- config that activates keymaps and enables snippet support
local function make_config()
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
return {
-- enable snippet support
capabilities = capabilities,
-- map buffer local keybindings when the language server attaches
on_attach = on_attach
}
end
-- lsp-install
local function setup_servers()
require'lspinstall'.setup()
-- get all installed servers
local servers = require'lspinstall'.installed_servers()
-- install server if not already installed but required
-- for _, server in pairs(required_servers) do
-- if not vim.tbl_contains(servers) then
-- require'lspinstall'.install_server(server)
-- end
-- end
-- Refresh servers list in case of newly installed servers
servers = require'lspinstall'.installed_servers()
for _, server in pairs(servers) do
local config = make_config()
-- language specific config
if server == "lua" then config.settings = lua_settings end
require'lspconfig'[server].setup(config)
-- Java LSP client is started by the plugin nvim-jdtls
if server == "java" then return end
end
end
setup_servers()
require('jdtls').start_or_attach({
cmd = {'java-lsp.sh'},
root_dir = require('jdtls.setup').find_root({'gradle.build', 'pom.xml'})
})
-- Automatically reload after `:LspInstall <server>` so we don't have to restart neovim
require'lspinstall'.post_install_hook = function()
setup_servers() -- reload installed servers
vim.cmd("bufdo e") -- this triggers the FileType autocmd that starts the server
end

View file

@ -0,0 +1,3 @@
require'lualine'.setup {
options = {theme = 'onedark'},
}

View file

@ -0,0 +1,36 @@
require('telescope').setup {
defaults = {
vimgrep_arguments = {
'rg', '--hidden', '--color=never', '--no-heading',
'--with-filename', '--line-number', '--column', '--smart-case'
},
prompt_prefix = "> ",
selection_caret = "> ",
entry_prefix = " ",
initial_mode = "insert",
selection_strategy = "reset",
sorting_strategy = "descending",
layout_strategy = "horizontal",
layout_config = {
horizontal = {mirror = false},
vertical = {mirror = false}
},
file_sorter = require'telescope.sorters'.get_fuzzy_file,
file_ignore_patterns = {},
generic_sorter = require'telescope.sorters'.get_generic_fuzzy_sorter,
winblend = 0,
border = {},
borderchars = {'', '', '', '', '', '', '', ''},
color_devicons = true,
use_less = true,
path_display = {},
set_env = {['COLORTERM'] = 'truecolor'}, -- default = nil,
file_previewer = require'telescope.previewers'.vim_buffer_cat.new,
grep_previewer = require'telescope.previewers'.vim_buffer_vimgrep.new,
qflist_previewer = require'telescope.previewers'.vim_buffer_qflist.new,
-- Developer configurations: Not meant for general override
buffer_previewer_maker = require'telescope.previewers'.buffer_previewer_maker
},
pickers = {find_files = {find_command = {"fd", "-Ht", "f"}}}
}

View file

@ -0,0 +1,6 @@
require'nvim-treesitter.configs'.setup {
ensure_installed = 'maintained',
highlight = {enable = true},
indent = {enable = true},
incremental_selection = {enable = true}
}

View file

@ -0,0 +1,90 @@
local fn = vim.fn
local cmd = vim.cmd
-- Install packer if it's not yet installed
local install_path = fn.stdpath('data') .. '/site/pack/packer/opt/packer.nvim'
local packer_not_installed = fn.empty(fn.glob(install_path))
if packer_not_installed > 0 then
print('Packer is not installed, cloning it now...')
cmd('silent !git clone https://github.com/wbthomason/packer.nvim ' ..
install_path)
end
-- Configure packer
cmd 'packadd packer.nvim'
local use = require('packer').use
require('packer').startup(function()
-- The plugin manager itself
use {'wbthomason/packer.nvim', opt = true}
-- Colorscheme
use 'monsonjeremy/onedark.nvim'
-- Statusline
use {
'hoob3rt/lualine.nvim',
requires = {'kyazdani42/nvim-web-devicons', opt = true}
}
-- Tabline/bufferline
use {
'akinsho/nvim-bufferline.lua',
requires = 'kyazdani42/nvim-web-devicons'
}
-- Indent characters
--use "lukas-reineke/indent-blankline.nvim"
-- Tree explorer
use {'kyazdani42/nvim-tree.lua', requires = 'kyazdani42/nvim-web-devicons'}
-- Telescope
use {
'nvim-telescope/telescope.nvim',
requires = {{'nvim-lua/popup.nvim'}, {'nvim-lua/plenary.nvim'}}
}
-- Do stuff as sudo
use 'lambdalisue/suda.vim'
-- Read editorconfig settings
use 'editorconfig/editorconfig-vim'
-- Configs for built-in LSP
use 'neovim/nvim-lspconfig'
-- Install LSP executables
use 'kabouzeid/nvim-lspinstall'
-- Extensions for eclipse.jdt.ls
use 'mfussenegger/nvim-jdtls'
-- Completion framework
use 'nvim-lua/completion-nvim'
-- treesitter syntax highlight
use {
'nvim-treesitter/nvim-treesitter',
branch = '0.5-compat',
run = ':TSUpdate'
}
-- Syntax highlighting for languages
-- that are not supported by treesitter
use 'sheerun/vim-polyglot'
-- Formatter plugin
use 'sbdchd/neoformat'
-- Make editing passwords safer
use {
'https://git.zx2c4.com/password-store',
rtp = 'contrib/vim/redact_pass.vim'
}
end)
-- Install plugins if packer was not installed
if packer_not_installed > 0 then cmd 'PackerInstall' end

View file

@ -0,0 +1,61 @@
local o = vim.o
local g = vim.g
local cmd = vim.cmd
------ Appearance ------
-- Set colorscheme
require('onedark').setup()
-- True colors
o.termguicolors = true
-- Floating window transparency
o.winblend = 10
-- Remove extra line
o.cmdheight = 1
-- Always show signcolumn
o.signcolumn = 'yes'
-- Blinking cursor
cmd 'set guicursor=i:ver1'
cmd 'set guicursor+=a:blinkon1'
-- Gutter and cursoline bg transparent
cmd 'highlight CursorLineNr guibg=transparent'
cmd 'highlight SignColumn guibg=transparent'
------ Misc -------
-- Use suda by default
g.suda_smart_edit = 1
-- Split direction
o.splitbelow = true
o.splitright = true
-- Case insensitive search
o.ignorecase = true
o.smartcase = true
-- Use mouse
o.mouse = 'a'
-- Use system clipboard
o.clipboard = 'unnamedplus'
-- Autoindent and syntax higlight
o.autoindent = true
o.smartindent = true
o.tabstop = 4
o.shiftwidth = 4
cmd 'syntax on'
cmd 'filetype on'
cmd 'filetype plugin indent on'
-- Disable auto commenting
o.formatoptions = 'cro'

View file

@ -0,0 +1,17 @@
#!/usr/bin/env bash
JAR="$HOME/.local/share/nvim/lspinstall/java/plugins/org.eclipse.equinox.launcher_*.jar"
GRADLE_HOME=$HOME/gradle /usr/lib/jvm/default/bin/java \
-Declipse.application=org.eclipse.jdt.ls.core.id1 \
-Dosgi.bundles.defaultStartLevel=4 \
-Declipse.product=org.eclipse.jdt.ls.core.product \
-Dlog.protocol=true \
-Dlog.level=ALL \
-Xms1g \
-Xmx2G \
-jar $(echo "$JAR") \
-configuration "$HOME/.local/share/nvim/lspinstall/java/config_linux" \
-data "${1:-$HOME/workspace}" \
--add-modules=ALL-SYSTEM \
--add-opens java.base/java.util=ALL-UNNAMED \
--add-opens java.base/java.lang=ALL-UNNAMED

View file

@ -149,7 +149,7 @@ update() {
}
plugins() {
vim +PlugUpgrade +PlugUpdate +CocUpdate +qa
nvim +PackerUpdate +TSUpdate +qa
zinit self-update
zinit update -p
$HOME/.tmux/plugins/tpm/bin/update_plugins all