From ce6be946d024aa55a15d576388d05f90be671cf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Gon=C3=A7alves?= Date: Sat, 8 Oct 2022 12:40:19 +0200 Subject: Sat Oct 8 12:40:19 PM CEST 2022 --- .config/nvim/after/ftplugin/dart.lua | 4 + .config/nvim/after/ftplugin/markdown.lua | 30 ++++ .config/nvim/after/ftplugin/python.lua | 4 + .config/nvim/after/ftplugin/yaml.lua | 6 + .config/nvim/after/queries/python/highlights.scm | 3 + .config/nvim/colors/colorscheme.vim | 9 + .config/nvim/init.lua | 1 + .config/nvim/init.old.vim | 218 ----------------------- .config/nvim/lua/diagnostic.lua | 45 +++++ .config/nvim/lua/keymaps.lua | 19 +- .config/nvim/lua/lsp.lua | 6 +- .config/nvim/lua/plugins.lua | 164 ----------------- .config/nvim/lua/plugins/aerial.lua | 32 ++++ .config/nvim/lua/plugins/bufresize.lua | 1 + .config/nvim/lua/plugins/cmp.lua | 26 +++ .config/nvim/lua/plugins/dap.lua | 21 +++ .config/nvim/lua/plugins/diffview.lua | 4 + .config/nvim/lua/plugins/gitsigns.lua | 14 ++ .config/nvim/lua/plugins/indent-guides.lua | 11 ++ .config/nvim/lua/plugins/indent-o-matic.lua | 14 ++ .config/nvim/lua/plugins/init.lua | 93 ++++++++++ .config/nvim/lua/plugins/lspconfig.lua | 82 +++++++++ .config/nvim/lua/plugins/sniprun.lua | 3 + .config/nvim/lua/plugins/telescope.lua | 25 +++ .config/nvim/lua/plugins/treesitter.lua | 18 ++ .config/nvim/lua/plugins/which-key.lua | 13 ++ .config/nvim/lua/plugins/zk.lua | 3 + .config/nvim/lua/settings.lua | 38 +++- 28 files changed, 501 insertions(+), 406 deletions(-) create mode 100755 .config/nvim/after/ftplugin/dart.lua create mode 100755 .config/nvim/after/queries/python/highlights.scm delete mode 100755 .config/nvim/init.old.vim create mode 100755 .config/nvim/lua/diagnostic.lua delete mode 100755 .config/nvim/lua/plugins.lua create mode 100755 .config/nvim/lua/plugins/aerial.lua create mode 100755 .config/nvim/lua/plugins/bufresize.lua create mode 100755 .config/nvim/lua/plugins/cmp.lua create mode 100755 .config/nvim/lua/plugins/dap.lua create mode 100755 .config/nvim/lua/plugins/diffview.lua create mode 100755 .config/nvim/lua/plugins/gitsigns.lua create mode 100755 .config/nvim/lua/plugins/indent-guides.lua create mode 100755 .config/nvim/lua/plugins/indent-o-matic.lua create mode 100755 .config/nvim/lua/plugins/init.lua create mode 100755 .config/nvim/lua/plugins/lspconfig.lua create mode 100755 .config/nvim/lua/plugins/sniprun.lua create mode 100755 .config/nvim/lua/plugins/telescope.lua create mode 100755 .config/nvim/lua/plugins/treesitter.lua create mode 100755 .config/nvim/lua/plugins/which-key.lua create mode 100755 .config/nvim/lua/plugins/zk.lua (limited to '.config/nvim') diff --git a/.config/nvim/after/ftplugin/dart.lua b/.config/nvim/after/ftplugin/dart.lua new file mode 100755 index 0000000..777faa6 --- /dev/null +++ b/.config/nvim/after/ftplugin/dart.lua @@ -0,0 +1,4 @@ +o.colorcolumn = '80' +bo.expandtab = true +bo.shiftwidth = 2 +bo.tabstop = 2 diff --git a/.config/nvim/after/ftplugin/markdown.lua b/.config/nvim/after/ftplugin/markdown.lua index bfcca96..3c7e009 100755 --- a/.config/nvim/after/ftplugin/markdown.lua +++ b/.config/nvim/after/ftplugin/markdown.lua @@ -6,3 +6,33 @@ bo.shiftwidth = 2 bo.formatoptions = 'qc' bo.textwidth = 80 o.colorcolumn = '80' + +if require("zk.util").notebook_root(vim.fn.expand('%:p')) ~= nil then + local function map(...) vim.api.nvim_buf_set_keymap(0, ...) end + local opts = { noremap=true, silent=false } + + map("n", "", "lua vim.lsp.buf.definition()", opts) + map("n", "K", "lua vim.lsp.buf.hover()", opts) + + vim.api.nvim_exec([[ + syn region markdownWikiLink matchgroup=markdownLinkDelimiter + \ start="\[\[" end="\]\]" contains=markdownUrl keepend oneline concealends + syn region markdownLink matchgroup=markdownLinkDelimiter + \ start="\[" end="\]" contains=markdownUrl keepend oneline concealends + syn region markdownLink matchgroup=markdownLinkDelimiter + \ start="(" end=")" contains=markdownUrl keepend contained conceal + syn region markdownLinkText matchgroup=markdownLinkTextDelimiter + \ start="!\=\[\%(\%(\_[^][]\|\[\_[^][]*\]\)*]\%( \=[[(]\)\)\@=" + \ end="\]\%( \=[[(]\)\@=" nextgroup=markdownLink,markdownId + \ skipwhite contains=@markdownInline,markdownLineStart concealends + + " unlet b:current_syntax + syntax include @Yaml syntax/yaml.vim + syntax include @Toml syntax/toml.vim + syntax region yamlFrontmatter start=/\%^---$/ end=/^---$/ + \ keepend contains=@Yaml + syntax region tomlFrontmatter start=/\%^+++$/ end=/^+++$/ + \ keepend contains=@Toml + + ]], true) +end diff --git a/.config/nvim/after/ftplugin/python.lua b/.config/nvim/after/ftplugin/python.lua index b6c54ff..64eb9f0 100755 --- a/.config/nvim/after/ftplugin/python.lua +++ b/.config/nvim/after/ftplugin/python.lua @@ -1 +1,5 @@ o.colorcolumn = '80' + +require"nvim-treesitter.highlight".set_custom_captures { + ["docstring"] = "Comment", +} diff --git a/.config/nvim/after/ftplugin/yaml.lua b/.config/nvim/after/ftplugin/yaml.lua index b89af72..4f9234b 100755 --- a/.config/nvim/after/ftplugin/yaml.lua +++ b/.config/nvim/after/ftplugin/yaml.lua @@ -4,3 +4,9 @@ o.colorcolumn = '80' bo.tabstop = 2 bo.softtabstop = 2 bo.shiftwidth = 2 + + +vim.api.nvim_exec([[ + set is hlsearch ai ic scs + nnoremap :nohls +]], true) diff --git a/.config/nvim/after/queries/python/highlights.scm b/.config/nvim/after/queries/python/highlights.scm new file mode 100755 index 0000000..4b664d4 --- /dev/null +++ b/.config/nvim/after/queries/python/highlights.scm @@ -0,0 +1,3 @@ +(block (expression_statement (string)) @docstring) + +(type) @type diff --git a/.config/nvim/colors/colorscheme.vim b/.config/nvim/colors/colorscheme.vim index 48df51c..e401231 100755 --- a/.config/nvim/colors/colorscheme.vim +++ b/.config/nvim/colors/colorscheme.vim @@ -209,3 +209,12 @@ sign define semshiError text=E> texthl=semshiErrorSign hi VirtColumn cterm=NONE ctermbg=0 ctermfg=2 hi IndentBlankLineChar cterm=NONE ctermbg=0 ctermfg=15 + + + + +" Highlight docstrings as comments, not string. +syn region pythonDocstring start=+^\s*[uU]\?[rR]\?"""+ end=+"""+ keepend excludenl contains=pythonEscape,@Spell,pythonDoctest,pythonDocTest2,pythonSpaceError +syn region pythonDocstring start=+^\s*[uU]\?[rR]\?'''+ end=+'''+ keepend excludenl contains=pythonEscape,@Spell,pythonDoctest,pythonDocTest2,pythonSpaceError + +hi def link pythonDocstring pythonComment diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index eda0497..5abff38 100755 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -5,6 +5,7 @@ cmd = vim.cmd require('settings') require('plugins') +require('diagnostic') require('lsp') require('statusline') require('keymaps') diff --git a/.config/nvim/init.old.vim b/.config/nvim/init.old.vim deleted file mode 100755 index 35630e8..0000000 --- a/.config/nvim/init.old.vim +++ /dev/null @@ -1,218 +0,0 @@ -" nvim configuration ~~ rgoncalves.se - -" vim-plug autoinstall -if empty(glob('~/.local/share/nvim/site/autoload/plug.vim')) - silent !curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs - \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim - autocmd VimEnter * PlugInstall --sync | source $MYVIMRC -endif - -" system agnostic detection -let uname = system('uname')[:-2] - -" global configuration -set encoding=utf-8 -set laststatus=2 -set scrolloff=3 -set viminfo= -set mouse=a -set title -set number -set noswapfile -set shell=/bin/sh -set updatetime=2500 -set synmaxcol=300 -set lazyredraw -set ttyfast -set wildoptions= -set autochdir -let sh_minlines=100 -let sh_maxlines=600 - -" filetypes and colorschemes -syntax on -filetype on -filetype plugin on -filetype indent on -colorscheme base - -" keybindings -noremap =j :%!python -m json.tool -noremap =k :%s/-\|-/-+-/g -noremap =l :%s/-+-/-\|-/g -noremap :NERDTreeToggle -noremap :GitGutterCustomToggle -inoremap -inoremap -inoremap -inoremap -" keybindings - omnifunc -inoremap pumvisible() ? "\" : "\" -inoremap pumvisible() ? "\" : "\" -inoremap pumvisible() ? '' : - \ '=pumvisible() ? "\Down>" : ""' -inoremap pumvisible() ? '' : - \ '=pumvisible() ? "\Down>" : ""' -inoremap (pumvisible() ? (col('.') > 1 ? 'i' : 'i') : '') . - \ '=pumvisible() ? "\C-n>\C-p>\Down>" : ""' -inoremap (pumvisible() ? (col('.') > 1 ? 'i' : 'i') : '') . - \ '=pumvisible() ? "\C-n>\C-p>\Down>" : ""' - -let g:polyglot_disabled = ['autoindent', 'sensible'] - -" PLUGINS list -if !empty(glob('~/.local/share/nvim/site/autoload/plug.vim')) - call plug#begin('~/.nvim/plugged/') - " core - Plug 'scrooloose/nerdtree' - " completion - Plug 'w0rp/ale' - " Plug 'davidhalter/jedi-vim' - Plug 'maralla/completor.vim' - " fzf - Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } - Plug 'junegunn/fzf.vim' - " indent - Plug 'nathanaelkane/vim-indent-guides' - Plug 'editorconfig/editorconfig-vim' - Plug 'pangloss/vim-javascript' - Plug 'pearofducks/ansible-vim' - Plug 'sheerun/vim-polyglot' - Plug 'dbeniamine/vim-mail' - Plug 'ap/vim-css-color' - " notes - Plug 'dhruvasagar/vim-table-mode' - Plug 'jceb/vim-orgmode' - " headers and source - Plug 'vim-scripts/a.vim' - Plug 'majutsushi/tagbar' - " git - Plug 'airblade/vim-gitgutter' - Plug 'tpope/vim-fugitive' - Plug 'jreybert/vimagit' - Plug 'junegunn/gv.vim' - " python - Plug 'petobens/poet-v' - call plug#end() -endif - -" indentation -set smarttab -set autoindent -set nocompatible -set tabstop=8 -set shiftwidth=8 -set softtabstop=8 -set noexpandtab -set list lcs=tab:\|\ ". -set fillchars+=vert:\ ". -set ve+=onemore -set list -set shortmess=atToOF - -" plugins settings -let g:ale_sign_error = '' -let g:ale_sign_warning = '' -let g:ale_c_clang_options='-std=gnu99 -Wall' -let g:ale_c_gcc_options='-std=gnu99 -Wall' -let g:ale_sh_shellcheck_options = '-e SC1090 SC2181 -e SC2155' -let g:ale_python_flake8_options = '--ignore=E501' -let g:ale_linters = { 'python': ['bandit', 'flake8'], } - -let g:gitgutter_max_signs = 500 -let g:gitgutter_sign_added = '+' -let g:gitgutter_sign_modified = '~' -let g:gitgutter_sign_removed = '-' -let g:gitgutter_sign_modified_removed = '-' - -let g:indent_guides_enable_on_vim_startup = 0 -let g:indent_guides_auto_colors = 0 -let g:indent_cuides_exclude_filetypes = [ - \'help', - \'terminal' - \] -let g:poetv_executables = ['poetry'] -let g:poetv_auto_activate = 1 - -let g:python_host_prog = system('which python2')[:-2] -let g:python3_host_prog = system('which python3')[:-2] -let g:jedi#auto_initialization = 1 -let g:jedi#popup_on_dot = 0 - -let g:NERDTreeAutoDeleteBuffer = 1 -let g:NERDTreeMinimalUI = 1 -let g:NERDTreeDirArrowExpandable = '+' -let g:NERDTreeDirArrowCollapsible = '-' - -let g:EditorConfig_exclude_patterns = ['fugitive://.*', 'scp://.*'] -let g:fzf_layout = { 'down': '40%'} -let g:magit_default_fold_level = 2 -let g:sql_type_default = 'pgsql' -let g:table_mode_always_active = 0 - -if uname == 'OpenBSD' - let g:ncm2_pyclang#library_path = '/usr/local/lib/libclang.so.8.1' - let g:completor_python_binary = '/usr/bin/python3' -endif - -" netrw -let g:netrw_banner = 0 -let g:netrw_browse_split = 4 -let g:netrw_liststyle = 3 -let g:netrw_altv = 1 -let g:netrw_winsize = 25 -let g:netrw_list_hide = '\(^\|\s\s\)\zs\.\S\+' - -autocmd BufNewFile,BufReadPost *.{yaml,yml} set filetype=yaml -autocmd BufNewFile,BufReadPost */*ssh/config.d/* set syntax=sshconfig -autocmd BufNewFile,BufReadPost */*ansible*/**/*.yml set filetype=yaml.ansible -autocmd BufNewFile,BufRead ~/.config/i3/config set filetype=i3config -autocmd BufNewFile,BufRead ~/.config/sway/config set filetype=i3config -autocmd BufNewFile,BufRead ~/.config/polybar/config set filetype=dosini -autocmd FileType conf let b:EditorConfig_disable = 1 -autocmd FileType gitcommit let b:EditorConfig_disable = 1 -autocmd FileType java setlocal omnifunc=javacomplete#Complete -autocmd FileType yaml let b:EditorConfig_disable = 1 - -" statusline -set statusline= -set statusline+=\ %f -set statusline+=%m -set statusline+=%= -set statusline+=\ %y -set statusline+=\ %{&fileencoding?&fileencoding:&encoding} -set statusline+=\ [%{&fileformat}\] -set statusline+=\ %p%% -set statusline+=\ %l:%c -set statusline+=\ - -" completion -set omnifunc=syntaxcomplete#Complete -set completeopt=longest,menuone - -" commands -command! PlugSync PlugClean | - \ PlugInstall | - \ UpdateRemotePlugins -command! GitGutterCustomToggle GitGutterLineHighlightsToggle | - \ GitGutterLineNrHighlightsToggle -command! Gblame Git blame - -" cnoremap :call CommandCallback() - -function! s:SyncColorcolumnColorscheme() - let l:length = '/\%' . string(&colorcolumn + 1) . 'v.\+/' - execute 'match' 'OverLength' l:length -endfunction - -function! s:CommandCallback() - let l:last_command = @: - - if l:last_command =~ 'set colorcolumn' - call s:SyncColorcolumnColorscheme() - endif -endfunction - -function! s:Init() - call s:SyncColorcolumnColorscheme() -endfunction diff --git a/.config/nvim/lua/diagnostic.lua b/.config/nvim/lua/diagnostic.lua new file mode 100755 index 0000000..0eb4e91 --- /dev/null +++ b/.config/nvim/lua/diagnostic.lua @@ -0,0 +1,45 @@ +local original_diagnostic_set = vim.diagnostic.set +local disabled_diagnostics_patterns = { + -- { 'mypy', 'Library stubs not installed' }, + -- { 'mypy', 'Cannot find implementation or library stub' }, + -- { 'mypy', 'Skipping analyzing' } +} + +local function is_diagnostic_disabled(diagnostic, disabled_diagnostic_patterns) + return string.find(diagnostic.source, disabled_diagnostic_patterns[1]) and + string.find(diagnostic.message, disabled_diagnostic_patterns[2]) +end + +local function is_diagnostic_enabled(diagnostic, disabled_diagnostic_patterns) + local found_diagnostic = true + for _, disabled_diagnostic_patterns in pairs(disabled_diagnostics_patterns) do + if is_diagnostic_disabled(diagnostic, disabled_diagnostic_patterns) then + found_diagnostic = false + end + end + return found_diagnostic +end + +vim.diagnostic.set = function(namespace, bufnr, diagnostics, opts) + local filtered_diagnostics = {} + for _, diagnostic in pairs(diagnostics) do + if is_diagnostic_enabled(diagnostic, disabled_diagnostics_patterns) then + table.insert(filtered_diagnostics, diagnostic) + end + end + original_diagnostic_set(namespace, bufnr, filtered_diagnostics, opts) +end + +vim.diagnostic.config{ + underline = false, + signs = true, + severity_sort = true, + update_in_insert = false, + float = { + source = 'always', + }, + virtual_text = { + prefix = '▒ ', + spacing = 8, + }, +} diff --git a/.config/nvim/lua/keymaps.lua b/.config/nvim/lua/keymaps.lua index 070ddc9..5243d8b 100755 --- a/.config/nvim/lua/keymaps.lua +++ b/.config/nvim/lua/keymaps.lua @@ -1,24 +1,9 @@ ---[[ --- Keymaps ---]] - local map = vim.api.nvim_set_keymap local cmd = vim.cmd - -options = {noremap=true} +local options = { noremap=true } map('i', '', '', options) map('i', '', '', options) map('i', '', '', options) map('i', '', '', options) -map('i', '', '', options) - -map('', '', ':NvimTreeToggle', options) - ---[[ -map('n', '', '', 'compe#complete()', options) -map('n', '', '', 'compe#confirm(\'\'', options) -map('n', '', '', 'compe#close(\'\'', options) -map('n', '', '', 'compe#scroll({\'delta\': +4}', options) -map('n', '', '', 'compe#scroll({\'delta\': -4}', options) ---]] +map('i', '', ' :noh', options) diff --git a/.config/nvim/lua/lsp.lua b/.config/nvim/lua/lsp.lua index 95d9409..4e0624c 100755 --- a/.config/nvim/lua/lsp.lua +++ b/.config/nvim/lua/lsp.lua @@ -1,9 +1,6 @@ ---[[ --- lsp ---]] - local lsp = vim.lsp +--[[ lsp.handlers["textDocument/publishDiagnostics"] = lsp.with( lsp.diagnostic.on_publish_diagnostics, { @@ -15,3 +12,4 @@ lsp.handlers["textDocument/publishDiagnostics"] = lsp.with( signs = true, } ) +--]] diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua deleted file mode 100755 index bb7a7b4..0000000 --- a/.config/nvim/lua/plugins.lua +++ /dev/null @@ -1,164 +0,0 @@ --- bootstrap paq -local install_path = vim.fn.stdpath('data')..'/site/pack/paqs/start/paq-nvim' -if vim.fn.empty(vim.fn.glob(install_path)) > 0 then - vim.fn.system({ - 'git', 'clone', '--depth=1', - 'https://github.com/savq/paq-nvim.git', - install_path - }) - vim.cmd 'packadd paq-nvim' -end - --- enable paq -vim.cmd 'packadd paq-nvim' - --- plugins -require('paq') { - {'savq/paq-nvim'}; - - -- treesiter / lsp - {'nvim-treesitter/playground'}; - {'nvim-treesitter/nvim-treesitter-textobjects'}; - { - 'nvim-treesitter/nvim-treesitter', - run=vim.api.nvim_command(':silent! TSUpdate') - }; - { - 'neovim/nvim-lspconfig', - run='python3 -m pipx install python-lsp-server[all]' - }; - - -- utils - {'folke/trouble.nvim'}; - {'hrsh7th/nvim-compe'}; - - {'hrsh7th/cmp-nvim-lsp'}; - {'hrsh7th/cmp-cmdline'}; - {'hrsh7th/cmp-buffer'}; - {'hrsh7th/cmp-path'}; - {'hrsh7th/cmp-calc'}; - {'hrsh7th/nvim-cmp'}; - - -- indent - {'lewis6991/gitsigns.nvim'}; - {'glepnir/indent-guides.nvim'}; - {'darazaki/indent-o-matic'}; - - -- dep - {'nvim-lua/plenary.nvim'}; -} - --- treesitter - -local parser_configs = require('nvim-treesitter.parsers').get_parser_configs() - -require('nvim-treesitter.configs').setup { - ensure_installed = 'maintained', - ignore_install = { - 'verilog', - 'kotlin' - }, - highlight = { enable = true }, - incremental_selection = { enable = true }, - textobjects = { enable = true } -} - --- completion - -local cmp = require('cmp') - -cmp.setup({ - mapping = { - [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), - }, - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, - { name = 'cmdline' }, - { name = 'path' }, - { name = 'calc' } - }, - { - { name = 'buffer' } - }) -}) - -cmp.setup.cmdline('/', { - sources = { - { name = 'buffer' } - } -}) - --- lsp configuration - -local lsputil = require('lspconfig/util') -local python_venv = require('utils').get_python_venv() -require('lspconfig').pylsp.setup{ - cmd = {'pylsp', '-v'}, - cmd_env = { - VIRTUAL_ENV = python_venv, - PATH = lsputil.path.join(python_venv, 'bin') .. ':' .. vim.env.PATH - }, -} - -require('lspconfig').clangd.setup{} -require('lspconfig').elixirls.setup{ cmd = {'elixir-ls'} } -require('lspconfig').eslint.setup{} -require('lspconfig').terraformls.setup{} - --- org - -require('trouble').setup{} - --- syntactic sugar - -require('indent_guides').setup{ - indent_enable=true; - exclude_filetypes={ - 'calendar', - 'gitcommit', - 'help', - 'NvimTree', - }; -} - -require('indent-o-matic').setup { - max_lines = 0, - standard_widths = { 2, 4, 8 }, - - filetype_ = { - standard_widths = { 2, 4 }, - }, - - filetype_css = { - max_lines = 4096, - }, - - filetype_scss = { - max_lines = 4096, - }, - - filetype_javascript = { - max_lines = 4096, - }, - - filetype_json = { - max_lines = 4096, - }, - - filetype_typescript = { - max_lines = 4096, - }, -} - -require('gitsigns').setup{ - signs = { - add = {hl = 'GitSignsAdd', text = '▍', numhl='GitSignsAddNr', linehl='GitSignsAddLn'}, - change = {hl = 'GitSignsChange', text = '▍', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'}, - delete = {hl = 'GitSignsDelete', text = '▍', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'}, - topdelete = {hl = 'GitSignsDelete', text = '▍', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'}, - changedelete = {hl = 'GitSignsChange', text = '▍', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'}, - } -} diff --git a/.config/nvim/lua/plugins/aerial.lua b/.config/nvim/lua/plugins/aerial.lua new file mode 100755 index 0000000..7b915db --- /dev/null +++ b/.config/nvim/lua/plugins/aerial.lua @@ -0,0 +1,32 @@ +require("aerial").setup{ + highlight_on_jump = 800, + min_width = 10, + filter_kind = { + "Array", + "Boolean", + "Class", + "Constant", + "Constructor", + "Enum", + "EnumMember", + "Event", + "Field", + "File", + "Function", + "Interface", + "Key", + "Method", + "Module", + "Namespace", + "Null", + "Number", + "Object", + "Operator", + "Package", + "Property", + "String", + "Struct", + "TypeParameter", + "Variable" + }, +} diff --git a/.config/nvim/lua/plugins/bufresize.lua b/.config/nvim/lua/plugins/bufresize.lua new file mode 100755 index 0000000..c4212f8 --- /dev/null +++ b/.config/nvim/lua/plugins/bufresize.lua @@ -0,0 +1 @@ +require('bufresize').setup{} diff --git a/.config/nvim/lua/plugins/cmp.lua b/.config/nvim/lua/plugins/cmp.lua new file mode 100755 index 0000000..503440f --- /dev/null +++ b/.config/nvim/lua/plugins/cmp.lua @@ -0,0 +1,26 @@ +local cmp = require('cmp') + +cmp.setup({ + mapping = { + [''] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), + -- [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), + -- [''] = cmp.mapping.confirm({ select = true }) + }, + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'cmdline' }, + { name = 'path' }, + { name = 'calc' } + }, + { + { name = 'buffer' } + }) +}) + +cmp.setup.cmdline('/', { + sources = { + { name = 'buffer' } + } +}) diff --git a/.config/nvim/lua/plugins/dap.lua b/.config/nvim/lua/plugins/dap.lua new file mode 100755 index 0000000..b927ca6 --- /dev/null +++ b/.config/nvim/lua/plugins/dap.lua @@ -0,0 +1,21 @@ +local dap = require('dap') +local python_venv = require('utils').get_python_venv() + +dap.adapters.python = { + type = 'executable'; + command = 'python'; + args = { '-m', 'debugpy.adapter' }; +} + +dap.configurations.python = { + { + type = 'python'; + request = 'launch'; + name = "Launch file"; + + program = "${file}"; + pythonPath = python_venv .. '/bin/python'; + }, +} + +-- require("dapui").setup{} diff --git a/.config/nvim/lua/plugins/diffview.lua b/.config/nvim/lua/plugins/diffview.lua new file mode 100755 index 0000000..857b041 --- /dev/null +++ b/.config/nvim/lua/plugins/diffview.lua @@ -0,0 +1,4 @@ +require('diffview').setup{ + diff_binaries = false, + enhanced_diff_hl = false, +} diff --git a/.config/nvim/lua/plugins/gitsigns.lua b/.config/nvim/lua/plugins/gitsigns.lua new file mode 100755 index 0000000..7c4a92b --- /dev/null +++ b/.config/nvim/lua/plugins/gitsigns.lua @@ -0,0 +1,14 @@ +require('gitsigns').setup{ + signs = { + add = {hl = 'GitSignsAdd', text = '▍', + numhl='GitSignsAddNr', linehl='GitSignsAddLn'}, + change = {hl = 'GitSignsChange', text = '▍', + numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'}, + delete = {hl = 'GitSignsDelete', text = '▍', + numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'}, + topdelete = {hl = 'GitSignsDelete', text = '▍', + numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'}, + changedelete = {hl = 'GitSignsChange', text = '▍', + numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'}, + } +} diff --git a/.config/nvim/lua/plugins/indent-guides.lua b/.config/nvim/lua/plugins/indent-guides.lua new file mode 100755 index 0000000..c50f74d --- /dev/null +++ b/.config/nvim/lua/plugins/indent-guides.lua @@ -0,0 +1,11 @@ +require('indent_guides').setup{ + indent_enable=true; + exclude_filetypes={ + 'calendar', + 'gitcommit', + 'help', + 'lsp-installer', + 'man', + 'NvimTree', + }; +} diff --git a/.config/nvim/lua/plugins/indent-o-matic.lua b/.config/nvim/lua/plugins/indent-o-matic.lua new file mode 100755 index 0000000..4b2abb5 --- /dev/null +++ b/.config/nvim/lua/plugins/indent-o-matic.lua @@ -0,0 +1,14 @@ +require('indent-o-matic').setup { + max_lines = 0, + standard_widths = { 2, 4, 8 }, + + filetype_ = { standard_widths = { 2, 4 } }, + + filetype_css = { max_lines = 4096 }, + filetype_scss = { max_lines = 4096 }, + filetype_json = { max_lines = 4096 }, + filetype_javascript = { max_lines = 4096 }, + filetype_typescript = { max_lines = 4096 }, + filetype_xml = { max_lines = 4096 }, + filetype_django = { max_lines = 4096 }, +} diff --git a/.config/nvim/lua/plugins/init.lua b/.config/nvim/lua/plugins/init.lua new file mode 100755 index 0000000..cd325d2 --- /dev/null +++ b/.config/nvim/lua/plugins/init.lua @@ -0,0 +1,93 @@ +-- bootstrap +local install_path = vim.fn.stdpath('data')..'/site/pack/paqs/start/paq-nvim' +if vim.fn.empty(vim.fn.glob(install_path)) > 0 then + vim.fn.system({ + 'git', 'clone', '--depth=1', + 'https://github.com/savq/paq-nvim.git', + install_path + }) +end + +vim.cmd 'packadd paq-nvim' + +require('paq') { + {'savq/paq-nvim'}; + + -- treesiter + {'nvim-treesitter/playground'}; + {'nvim-treesitter/nvim-treesitter-textobjects'}; + { + 'nvim-treesitter/nvim-treesitter', + run=vim.api.nvim_command(':silent! TSUpdate') + }; + + -- lsp + { + 'neovim/nvim-lspconfig', + run = function() + vim.fn.system({'npm', 'install', '-g', '@ansible/ansible-language-server'}) + vim.fn.system({'npm', 'install', '-g', 'vscode-langservers-extracted'}) + vim.fn.system({'python3', '-m', 'pipx', 'install', '--force', 'python-lsp-server[all]'}) + vim.fn.system({'python3', '-m', 'pipx', 'inject', 'python-lsp-server', 'git+https://github.com/python/mypy'}) + vim.fn.system({'python3', '-m', 'pipx', 'inject', 'python-lsp-server', 'pylsp-mypy'}) + vim.fn.system({'python3', '-m', 'pipx', 'inject', 'python-lsp-server', 'types-all'}) + vim.fn.system({'python3', '-m', 'pipx', 'upgrade', '--include-injected', 'python-lsp-server'}) + -- vim.fn.system({'python3', '-m', 'pip', 'install', '--force', 'debugpy'}) + end + }; + {'mickael-menu/zk-nvim'}; + + {'nvim-telescope/telescope.nvim'}; + {'stevearc/aerial.nvim'}; + {'sindrets/diffview.nvim'}; + {'folke/which-key.nvim'}; + { + 'michaelb/sniprun', + run = 'bash install.sh' + }; + + -- dap + {'mfussenegger/nvim-dap'}; + {'rcarriga/nvim-dap-ui'}; + + -- completion + {'hrsh7th/cmp-nvim-lsp'}; + {'hrsh7th/cmp-cmdline'}; + {'hrsh7th/cmp-buffer'}; + {'hrsh7th/cmp-path'}; + {'hrsh7th/cmp-calc'}; + {'hrsh7th/nvim-cmp'}; + + -- indentation + {'lewis6991/gitsigns.nvim'}; + {'glepnir/indent-guides.nvim'}; + {'darazaki/indent-o-matic'}; + { + 'stsewd/sphinx.nvim', + run=function() + vim.fn.system({'python3', '-m', 'pip', 'install', 'sphinx'}) + vim.api.nvim_command(':silent! UpdateRemotePlugins') + end + }; + + -- qol + {'kwkarlwang/bufresize.nvim'}; + + -- dependencies + {'nvim-lua/plenary.nvim'}; +} + +require('plugins.aerial') +require('plugins.bufresize') +require('plugins.cmp') +-- require('plugins.dap') +require('plugins.diffview') +require('plugins.gitsigns') +require('plugins.indent-guides') +require('plugins.indent-o-matic') +require('plugins.sniprun') +require('plugins.lspconfig') +require('plugins.telescope') +require('plugins.treesitter') +require('plugins.which-key') +require('plugins.zk') diff --git a/.config/nvim/lua/plugins/lspconfig.lua b/.config/nvim/lua/plugins/lspconfig.lua new file mode 100755 index 0000000..9ef6a1d --- /dev/null +++ b/.config/nvim/lua/plugins/lspconfig.lua @@ -0,0 +1,82 @@ +local opts = { noremap=true, silent=true } + +local lsputil = require('lspconfig/util') +local python_venv = require('utils').get_python_venv() + +local on_attach = function(client, bufnr) + -- Enable completion triggered by + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + + -- Mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', 'lua vim.lsp.buf.declaration()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', 'lua vim.lsp.buf.definition()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', 'lua vim.lsp.buf.hover()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', 'lua vim.lsp.buf.implementation()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', 'lua vim.lsp.buf.references()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'D', 'lua vim.lsp.buf.type_definition()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'rn', 'lua vim.lsp.buf.rename()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ca', 'lua vim.lsp.buf.code_action()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'f', 'lua vim.lsp.buf.formatting()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', '', 'lua vim.lsp.buf.signature_help()', opts) + + require("aerial").on_attach(client, bufnr) +end + +vim.api.nvim_set_keymap('n', 'd', 'lua vim.diagnostic.open_float()', opts) +vim.api.nvim_set_keymap('n', '[d', 'lua vim.diagnostic.goto_prev()', opts) +vim.api.nvim_set_keymap('n', ']d', 'lua vim.diagnostic.goto_next()', opts) +vim.api.nvim_set_keymap('n', 'q', 'lua vim.diagnostic.setloclist()', opts) + +require('lspconfig').ansiblels.setup{ on_attach = on_attach } +require('lspconfig').clangd.setup{ on_attach = on_attach } +require('lspconfig').eslint.setup{ on_attach = on_attach } +require('lspconfig').gopls.setup{ on_attach = on_attach } +require('lspconfig').terraformls.setup{ on_attach = on_attach } + +require('lspconfig').dartls.setup{ + on_attach = on_attach, + settings = { + dart = { + analysisExcludedFolders = { '.git' }, + completeFunctionCalls = true, + enableSdkFormatter = true, + showTodos = true + } + } +} + +require('lspconfig').pylsp.setup{ + cmd_env = { + VIRTUAL_ENV = python_venv, + PATH = lsputil.path.join(python_venv, 'bin') .. ':' .. vim.env.PATH, + MYPYPATH = lsputil.path.join(python_venv, 'bin') .. ':' .. (vim.env.MYPYPATH or "") + }, + on_attach = on_attach, + settings = { + pylsp = { + configurationSources = {'flake8', 'pycodestyle'}, + plugins = { + flake8 = { + enabled = true, + ignore = {}, + maxLineLength = 160 + }, + rope_completion = { + enabled = true, + }, + pyflakes = { + enabled = true + }, + } + } + } +} + +require('lspconfig').elixirls.setup{ + cmd = {'elixir-ls'}, + on_attach = on_attach +} diff --git a/.config/nvim/lua/plugins/sniprun.lua b/.config/nvim/lua/plugins/sniprun.lua new file mode 100755 index 0000000..d6d1265 --- /dev/null +++ b/.config/nvim/lua/plugins/sniprun.lua @@ -0,0 +1,3 @@ +require('sniprun').setup{ + display = { 'Terminal' }, +} diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua new file mode 100755 index 0000000..6a5f8c6 --- /dev/null +++ b/.config/nvim/lua/plugins/telescope.lua @@ -0,0 +1,25 @@ +require('telescope').setup{ + defaults = { + borderchars = { '─', '│', '─', '│', '┌', '┐', '┘', '└'} + } +} + +require('telescope').load_extension('aerial') + +local opt = { noremap=true } +local keybinds = { + {'fa', 'aerial'}, + {'fb', 'buffers'}, + {'ff', 'find_files'}, + {'fg', 'git_files'}, + {'fl', 'live_grep'}, + {'fh', 'help_tags'}, + {'fm', 'man_pages'}, + {'fo', 'oldfiles'}, + {'fr', 'resume'}, + {'f/', 'current_buffer_fuzzy_find'}, +} + +for _, keybind in pairs(keybinds) do + vim.api.nvim_set_keymap('n', keybind[1], 'Telescope ' .. keybind[2] .. '', opt) +end diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua new file mode 100755 index 0000000..7fb6d45 --- /dev/null +++ b/.config/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,18 @@ +require('nvim-treesitter.configs').setup { + ensure_installed = 'all', + ignore_install = { + 'verilog', + 'kotlin' + }, + highlight = { + enable = true, + -- additional_vim_regex_highlighting = { "markdown" } + additional_vim_regex_highlighting = true, + set_custom_captures = { + ["type.string"] = "pythonFunction", + } + }, + incremental_selection = { enable = true }, + textobjects = { enable = true } +} + diff --git a/.config/nvim/lua/plugins/which-key.lua b/.config/nvim/lua/plugins/which-key.lua new file mode 100755 index 0000000..93e19f9 --- /dev/null +++ b/.config/nvim/lua/plugins/which-key.lua @@ -0,0 +1,13 @@ +require("which-key").setup{ + window = { + position = "bottom", -- bottom, top + margin = { 1, 40, 1, 0 }, -- extra window margin [top, right, bottom, left] + padding = { 0, 0, 0, 0 }, -- extra window padding [top, right, bottom, left] + winblend = 0 + }, + icons = { + breadcrumb = ">", -- symbol used in the command line area that shows your active key combo + separator = ":", -- symbol used between a key and it's label + group = "+", -- symbol prepended to a group + }, +} diff --git a/.config/nvim/lua/plugins/zk.lua b/.config/nvim/lua/plugins/zk.lua new file mode 100755 index 0000000..1a091b9 --- /dev/null +++ b/.config/nvim/lua/plugins/zk.lua @@ -0,0 +1,3 @@ +require('zk').setup{ + picker = 'telescope' +} diff --git a/.config/nvim/lua/settings.lua b/.config/nvim/lua/settings.lua index aa04dce..ef8fb95 100755 --- a/.config/nvim/lua/settings.lua +++ b/.config/nvim/lua/settings.lua @@ -11,12 +11,21 @@ o.autochdir = false o.smarttab = true o.number = true o.list = true +o.mouse = '' o.swapfile = false -- o.foldmethod = 'expr' -- o.foldexpr = 'nvim_treesitter#foldexpr()' +local format = function(diagnostic) + if diagnostic.severity == vim.diagnostic.severity.ERROR then + -- return string.format("E: %s", diagnostic.message) + return diagnostic.message .. diagnostic.source + end + return diagnostic.message +end + cmd 'syntax enable' cmd 'filetype on' cmd 'filetype plugin on' @@ -24,7 +33,30 @@ cmd 'filetype indent on' cmd 'colorscheme colorscheme' vim.cmd([[ -au BufNewFile,BufRead *.Dockerfile,Dockerfile.* setlocal filetype=dockerfile -au BufNewFile,BufRead *.j2*,*.jinja* setlocal filetype=django -au BufNewFile,BufRead *.env* setlocal filetype=sh + au BufNewFile,BufRead *.Dockerfile,Dockerfile.* setlocal filetype=dockerfile + au BufNewFile,BufRead *.j2*,*.jinja* setlocal filetype=django + au BufNewFile,BufRead */task/config setlocal filetype=taskrc + au BufNewFile,BufRead *.env* setlocal filetype=sh + + au BufNewFile,BufRead */playbooks/*.yml set filetype=yaml.ansible + + au BufNewFile,BufRead */.config/neomutt/* + \ if &filetype == "" | + \ setlocal filetype=neomuttrc | + \ endif ]]) + +--[[ +require'nvim-treesitter.configs'.setup { + textobjects = { + lsp_interop = { + enable = true, + border = 'none', + peek_definition_code = { + ["k"] = "@function.outer", + ["K"] = "@class.outer", + }, + }, + }, +} +]]-- -- cgit v1.2.3