split neovim and vim configs, make vim less IDE-like

This commit is contained in:
Diego Fernando Carrión 2024-10-11 12:55:10 +02:00
parent d529e27645
commit 49fd493194
No known key found for this signature in database
GPG Key ID: A286B34D5CFB3404
45 changed files with 80 additions and 494 deletions

View File

@ -1,23 +0,0 @@
{
"pylsp.builtin.enableInstallPylspMypy": true,
"pylsp.builtin.enableInstallPylsIsort": true,
"pylsp.builtin.enableInstallPylspRope": true,
"pylsp.plugins.pyflakes.enabled": false,
"pylsp.plugins.pylint.enabled": true,
"pylsp.plugins.pylint.executable": "pylint",
"pylsp.plugins.pylint.args": [
"--disable=line-too-long,import-error,too-many-arguments,too-many-locals,too-many-branches,too-many-lines,too-many-return-statements,fixme,too-few-public-methods,too-many-instance-attributes,too-many-statements,too-many-public-methods"
],
"pylsp.plugins.pycodestyle.enabled": false,
"pylsp.plugins.autopep8.enabled": false,
"pylsp.plugins.flake8.enabled": true,
"pylsp.plugins.flake8.maxComplexity": 15,
"pylsp.plugins.yapf.enabled": true,
"pylsp.plugins.mccabe.enabled": false,
"pylsp.plugins.pydocstyle.enabled": true,
"pylsp.plugins.pydocstyle.convention": "google",
"pydocstring.formatter": "google",
"yaml.enable": true,
"yaml.validate": true,
"snippets.ultisnips.pythonPrompt": false
}

View File

@ -1 +0,0 @@
vimrc

View File

@ -1,64 +0,0 @@
require("todo-comments").setup({
signs = true, -- show icons in the signs column
sign_priority = 8, -- sign priority
-- keywords recognized as todo comments
keywords = {
FIX = {
icon = "", -- icon used for the sign, and in search results
color = "error", -- can be a hex color, or a named color (see below)
alt = { "FIXME", "BUG", "FIXIT", "ISSUE" }, -- a set of other keywords that all map to this FIX keywords
-- signs = false, -- configure signs for some keywords individually
},
TODO = { icon = "", color = "info" },
HACK = { icon = "", color = "warning" },
-- WARN = { icon = " ", color = "warning", alt = { "WARNING", "XXX" } },
-- PERF = { icon = " ", alt = { "OPTIM", "PERFORMANCE", "OPTIMIZE" } },
-- NOTE = { icon = " ", color = "hint", alt = { "INFO" } },
-- TEST = { icon = "⏲ ", color = "test", alt = { "TESTING", "PASSED", "FAILED" } },
},
gui_style = {
fg = "NONE", -- The gui style to use for the fg highlight group.
bg = "BOLD", -- The gui style to use for the bg highlight group.
},
merge_keywords = false, -- when true, custom keywords will be merged with the defaults
-- highlighting of the line containing the todo comment
-- * before: highlights before the keyword (typically comment characters)
-- * keyword: highlights of the keyword
-- * after: highlights after the keyword (todo text)
highlight = {
multiline = true, -- enable multine todo comments
multiline_pattern = "^.", -- lua pattern to match the next multiline from the start of the matched keyword
multiline_context = 10, -- extra lines that will be re-evaluated when changing a line
before = "", -- "fg" or "bg" or empty
keyword = "wide", -- "fg", "bg", "wide", "wide_bg", "wide_fg" or empty. (wide and wide_bg is the same as bg, but will also highlight surrounding characters, wide_fg acts accordingly but with fg)
after = "fg", -- "fg" or "bg" or empty
pattern = [[.*<(KEYWORDS)\s*:]], -- pattern or table of patterns, used for highlighting (vim regex)
comments_only = true, -- uses treesitter to match keywords in comments only
max_line_len = 400, -- ignore lines longer than this
exclude = {}, -- list of file types to exclude highlighting
},
-- list of named colors where we try to extract the guifg from the
-- list of highlight groups or use the hex color if hl not found as a fallback
colors = {
error = { "DiagnosticError", "ErrorMsg", "#DC2626" },
warning = { "DiagnosticWarn", "WarningMsg", "#FBBF24" },
info = { "DiagnosticInfo", "#2563EB" },
hint = { "DiagnosticHint", "#10B981" },
default = { "Identifier", "#7C3AED" },
test = { "Identifier", "#FF00FF" }
},
search = {
command = "rg",
args = {
"--color=never",
"--no-heading",
"--with-filename",
"--line-number",
"--column",
},
-- regex that will be used to match keywords.
-- don't replace the (KEYWORDS) placeholder
pattern = [[\b(KEYWORDS):]], -- ripgrep regex
-- pattern = [[\b(KEYWORDS)\b]], -- match without the extra colon. You'll likely get false positives
},
})

View File

@ -1,42 +0,0 @@
require("nvim-treesitter.configs").setup({
ensure_installed = {
"bash",
"c",
"comment",
"cpp",
"css",
"dockerfile",
"git_rebase",
"gitcommit",
"gitignore",
"go",
"gomod",
"gosum",
"hcl",
"html",
"java",
"javascript",
"json",
"lua",
"make",
"markdown",
"perl",
"rego",
"ruby",
"rust",
"sql",
"terraform",
"toml",
"tsx",
"typescript",
"vim",
"yaml",
},
sync_install = false,
auto_install = true,
highlight = {
enable = true,
disable = { "markdown", "make"},
additional_vim_regex_highlighting = true,
},
})

View File

@ -1,37 +0,0 @@
local function on_venv_activate()
local command_run = false
local function run_shell_command()
local venv = require("venv-selector").venv():match("([^/]+)$")
if command_run == false then
local command = "workon " .. venv
vim.api.nvim_feedkeys(command .. "\n", "n", false)
command_run = true
end
end
vim.api.nvim_create_augroup("TerminalCommands", { clear = true })
vim.api.nvim_create_autocmd("TermEnter", {
group = "TerminalCommands",
pattern = "*",
callback = run_shell_command,
})
vim.print("Activated venv: " .. require("venv-selector").venv())
end
require("venv-selector").setup {
settings = {
options = {
on_venv_activate_callback = on_venv_activate,
notify_user_on_venv_activation = true,
},
search = {
my_venvs = {
command = "ls -d ~/devel/venvs/*/",
},
},
},
}

View File

@ -1,21 +0,0 @@
-- enable format-on-save from nvim-lspconfig + ZLS
--
local lspconfig = require('lspconfig')
lspconfig.zls.setup {
-- Server-specific settings. See `:help lspconfig-setup`
-- omit the following line if `zls` is in your PATH
-- cmd = { '/path/to/zls_executable' },
-- There are two ways to set config options:
-- - edit your `zls.json` that applies to any editor that uses ZLS
-- - set in-editor config options with the `settings` field below.
--
-- Further information on how to configure ZLS:
-- https://github.com/zigtools/zls/wiki/Configuration
-- settings = {
-- zls = {
-- -- omit the following line if `zig` is in your PATH
-- zig_exe_path = '/path/to/zig_executable',
-- }
-- }
}

View File

@ -18,17 +18,17 @@ fi
alias k=kubectl
# Vim
if [ -x "$(command -v nvim)" ] && ! limited_terminal
then
vim_path="$(command -v vim)"
if [ -x "$vim_path" ]
then
alias vvim=$vim_path
alias vim=nvim
alias vimdiff="nvim -d"
fi
fi
## Vim
#if [ -x "$(command -v nvim)" ] && ! limited_terminal
#then
# vim_path="$(command -v vim)"
# if [ -x "$vim_path" ]
# then
# alias vvim=$vim_path
# alias vim=nvim
# alias vimdiff="nvim -d"
# fi
#fi
if [ -x "$(command -v neomutt)" ]
then

6
home/any/neovim.dirs Normal file
View File

@ -0,0 +1,6 @@
.config/nvim/autoload
.config/nvim/colors
.config/nvim/plugged
.config/nvim/session
.config/nvim/spell
.var/tmp/nvim/

View File

@ -75,6 +75,52 @@ return {
}
}
end,
pylsp = function()
local lspconfig = require("lspconfig")
lspconfig.pylsp.setup {
settings = {
pylsp = {
plugins = {
autopep8 = { enabled = false },
mccabe = { enabled = false },
pycodestyle = { enabled = false },
pyflakes = { enabled = false },
rope = { enabled = false },
black = {
enabled = true,
},
flake8 = {
enabled = true,
maxComplexity = 15,
},
jedi_completion = {
fuzzy = true,
},
pydocstyle = {
enabled = true,
convention = "google",
},
pylint = {
enabled = true,
executable = "pylint",
args = {
"--disable=line-too-long,import-error,too-many-arguments,too-many-locals,too-many-branches,too-many-lines,too-many-return-statements,fixme,too-few-public-methods,too-many-instance-attributes,too-many-statements,too-many-public-methods",
},
},
pylsp_isort = {
enabled = true,
},
pylsp_mypy = {
enabled = true,
},
yapf = {
enabled = true,
},
}
}
}
}
end
}
})
@ -89,7 +135,7 @@ return {
mapping = cmp.mapping.preset.insert({
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
['<C-y>'] = cmp.mapping.confirm({ select = true }),
['<tab>'] = cmp.mapping.confirm({ select = true }),
["<C-Space>"] = cmp.mapping.complete(),
}),
sources = cmp.config.sources({

View File

@ -10,11 +10,10 @@ vim.opt.expandtab = false
vim.opt.smartindent = true
vim.opt.wrap = false
vim.opt.wrap = true
vim.opt.swapfile = false
vim.opt.backup = false
vim.opt.undodir = "/.var/tmp/vim/undodir"
vim.opt.undofile = true
vim.opt.hlsearch = false
@ -30,8 +29,8 @@ vim.opt.updatetime = 50
vim.opt.colorcolumn = "80"
vim.opt.backupdir = os.getenv("HOME") .. "/.var/tmp/vim/backup/"
vim.opt.directory = os.getenv("HOME") .. "/.var/tmp/vim/swap/"
vim.opt.undodir = os.getenv("HOME") .. "/.var/tmp/vim/undo/"
vim.opt.backupdir = os.getenv("HOME") .. "/.var/tmp/nvim/backup/"
vim.opt.directory = os.getenv("HOME") .. "/.var/tmp/nvim/swap/"
vim.opt.undodir = os.getenv("HOME") .. "/.var/tmp/nvim/undo/"
vim.opt.listchars = {tab = '', trail = ''}
vim.opt.list = true

View File

@ -1,6 +1,2 @@
.config/nvim/autoload
.config/nvim/colors
.config/nvim/plugged
.config/nvim/session
.config/nvim/spell
.vim/
.var/tmp/vim/

View File

@ -3,7 +3,7 @@
"*****************************************************************************
"" Vim-Plug core
"*****************************************************************************
let vimplug_exists=expand('~/.config/nvim/autoload/plug.vim')
let vimplug_exists=expand('~/.vim/autoload/plug.vim')
if has('win32')&&!has('win64')
let curl_exists=expand('C:\Windows\Sysnative\curl.exe')
else
@ -11,7 +11,7 @@ else
endif
let g:vim_bootstrap_langs = "c,go,lua,python,ruby,rust"
let g:vim_bootstrap_editor = "nvim" " nvim or vim
let g:vim_bootstrap_editor = "vim" " nvim or vim
let g:vim_bootstrap_theme = "gruvbox"
let g:vim_bootstrap_frams = ""
@ -29,7 +29,7 @@ if !filereadable(vimplug_exists)
endif
" Required:
call plug#begin(expand('~/.config/nvim/plugged'))
call plug#begin(expand('~/.vim/plugged'))
"*****************************************************************************
"" Plug install packages
@ -42,8 +42,6 @@ Plug 'airblade/vim-gitgutter'
Plug 'vim-scripts/grep.vim'
Plug 'vim-scripts/CSApprox'
Plug 'Raimondi/delimitMate'
Plug 'majutsushi/tagbar'
Plug 'dense-analysis/ale'
Plug 'Yggdroot/indentLine'
Plug 'editor-bootstrap/vim-bootstrap-updater'
Plug 'tpope/vim-rhubarb' " required by fugitive to :GBrowse
@ -52,13 +50,6 @@ Plug 'morhetz/gruvbox'
if empty($VI)
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'psliwka/vim-smoothie'
endif
if has('nvim')
Plug 'github/copilot.vim'
Plug 'akinsho/toggleterm.nvim', {'tag' : 'v2.11.0'}
Plug 'neovim/nvim-lspconfig'
Plug 'folke/todo-comments.nvim'
endif
if isdirectory('/usr/local/opt/fzf')
@ -87,75 +78,12 @@ Plug 'xolox/vim-session'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
"*****************************************************************************
"" Custom bundles
"*****************************************************************************
" c
Plug 'vim-scripts/c.vim', {'for': ['c', 'cpp']}
Plug 'ludwig/split-manpage.vim'
" go
"" Go Lang Bundle
Plug 'fatih/vim-go', {'do': ':GoInstallBinaries'}
" lua
"" Lua Bundle
Plug 'xolox/vim-lua-ftplugin'
Plug 'xolox/vim-lua-inspect'
" python
"" Python Bundle
Plug 'davidhalter/jedi-vim'
Plug 'raimon49/requirements.txt.vim', {'for': 'requirements'}
" ruby
Plug 'tpope/vim-rails'
Plug 'tpope/vim-rake'
Plug 'tpope/vim-projectionist'
Plug 'thoughtbot/vim-rspec'
Plug 'ecomba/vim-ruby-refactoring', {'tag': 'main'}
" rust
" Vim racer
Plug 'racer-rust/vim-racer'
" Rust.vim
Plug 'rust-lang/rust.vim'
" Async.vim
Plug 'prabirshrestha/async.vim'
" Vim lsp
Plug 'prabirshrestha/vim-lsp'
" Asyncomplete.vim
Plug 'prabirshrestha/asyncomplete.vim'
" Asyncomplete lsp.vim
Plug 'prabirshrestha/asyncomplete-lsp.vim'
" Zig
"" Zig Bundle
Plug 'neovim/nvim-lspconfig' " https://github.com/neovim/nvim-lspconfig
Plug 'ziglang/zig.vim' " https://github.com/ziglang/zig.vim
" Mojo
Plug 'czheo/mojo.vim'
"*****************************************************************************
"*****************************************************************************
"" Include user's extra bundle
if filereadable(expand("~/.config/nvim/local_bundles.vim"))
source ~/.config/nvim/local_bundles.vim
if filereadable(expand("~/.vim/local_bundles.vim"))
source ~/.vim/local_bundles.vim
endif
call plug#end()
@ -177,10 +105,9 @@ set fileencodings=utf-8
set backspace=indent,eol,start
"" Tabs. May be overridden by autocmd rules
set tabstop=4
set tabstop=2
set softtabstop=0
set shiftwidth=4
""""""set expandtab
set shiftwidth=2
"" Map leader to ,
let mapleader=' '
@ -189,7 +116,7 @@ let mapleader=' '
set hidden
"" Searching
set hlsearch
set nohlsearch
set incsearch
set ignorecase
set smartcase
@ -203,7 +130,7 @@ else
endif
" session management
let g:session_directory = "~/.config/nvim/session"
let g:session_directory = "~/.vim/session"
let g:session_autoload = "no"
let g:session_autosave = "no"
let g:session_command_aliases = 1
@ -253,8 +180,8 @@ endif
"" Disable the blinking cursor.
" set gcr=a:blinkon0
au TermEnter * setlocal scrolloff=0
au TermLeave * setlocal scrolloff=3
" au TermEnter * setlocal scrolloff=0
" au TermLeave * setlocal scrolloff=3
"" Status bar
@ -283,7 +210,6 @@ endif
let g:airline_theme = 'powerlineish'
let g:airline_powerline_fonts = 1
let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#ale#enabled = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tagbar#enabled = 1
let g:airline_skip_empty_sections = 1
@ -451,9 +377,6 @@ let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<c-b>"
let g:UltiSnipsEditSplit="vertical"
" ale
let g:ale_linters = {}
" Tagbar
nmap <silent> <F8> :TagbarToggle<CR>
let g:tagbar_autofocus = 1
@ -508,206 +431,10 @@ vnoremap K :m '<-2<CR>gv=gv
"" Open current line on GitHub
""""""nnoremap <Leader>o :.GBrowse<CR>
""" toggleterm
if has('nvim')
lua require("toggleterm").setup()
nnoremap <leader>t :ToggleTerm direction=float<CR>
endif
"*****************************************************************************
"" Custom configs
"*****************************************************************************
" c
autocmd FileType c setlocal tabstop=4 shiftwidth=4 expandtab
autocmd FileType cpp setlocal tabstop=4 shiftwidth=4 expandtab
" go
" vim-go
" run :GoBuild or :GoTestCompile based on the go file
function! s:build_go_files()
let l:file = expand('%')
if l:file =~# '^\f\+_test\.go$'
call go#test#Test(0, 1)
elseif l:file =~# '^\f\+\.go$'
call go#cmd#Build(0)
endif
endfunction
let g:go_list_type = "quickfix"
let g:go_fmt_command = "goimports"
let g:go_fmt_fail_silently = 1
let g:go_highlight_types = 1
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
let g:go_highlight_structs = 1
let g:go_highlight_generate_tags = 1
let g:go_highlight_space_tab_error = 0
let g:go_highlight_array_whitespace_error = 0
let g:go_highlight_trailing_whitespace_error = 0
let g:go_highlight_extra_types = 1
autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 softtabstop=4
augroup completion_preview_close
autocmd!
if v:version > 703 || v:version == 703 && has('patch598')
autocmd CompleteDone * if !&previewwindow && &completeopt =~ 'preview' | silent! pclose | endif
endif
augroup END
augroup go
au!
au Filetype go command! -bang A call go#alternate#Switch(<bang>0, 'edit')
au Filetype go command! -bang AV call go#alternate#Switch(<bang>0, 'vsplit')
au Filetype go command! -bang AS call go#alternate#Switch(<bang>0, 'split')
au Filetype go command! -bang AT call go#alternate#Switch(<bang>0, 'tabe')
au FileType go nmap <Leader>dd <Plug>(go-def-vertical)
au FileType go nmap <Leader>dv <Plug>(go-doc-vertical)
au FileType go nmap <Leader>db <Plug>(go-doc-browser)
au FileType go nmap <leader>r <Plug>(go-run)
au FileType go nmap <leader>gt <Plug>(go-test)
au FileType go nmap <Leader>ct <Plug>(go-coverage-toggle)
au FileType go nmap <Leader>i <Plug>(go-info)
au FileType go nmap <silent> <Leader>l <Plug>(go-metalinter)
au FileType go nmap <C-g> :GoDecls<cr>
au FileType go nmap <leader>dr :GoDeclsDir<cr>
au FileType go imap <C-g> <esc>:<C-u>GoDecls<cr>
au FileType go imap <leader>dr <esc>:<C-u>GoDeclsDir<cr>
au FileType go nmap <leader>rb :<C-u>call <SID>build_go_files()<CR>
augroup END
" ale
:call extend(g:ale_linters, {
\"go": ['golint', 'go vet'], })
" lua
" python
" vim-python
augroup vimrc-python
autocmd!
autocmd FileType python setlocal expandtab shiftwidth=4 tabstop=8 colorcolumn=79
\ formatoptions+=croq softtabstop=4
\ cinwords=if,elif,else,for,while,try,except,finally,def,class,with
augroup END
" jedi-vim
let g:jedi#popup_on_dot = 0
let g:jedi#goto_assignments_command = "<leader>g"
let g:jedi#goto_definitions_command = "<leader>d"
let g:jedi#documentation_command = "K"
let g:jedi#usages_command = "<leader>n"
let g:jedi#rename_command = "<leader>r"
let g:jedi#show_call_signatures = "0"
let g:jedi#completions_command = "<C-Space>"
let g:jedi#smart_auto_mappings = 0
" ale
:call extend(g:ale_linters, {
\'python': ['flake8'], })
" vim-airline
let g:airline#extensions#virtualenv#enabled = 1
" Syntax highlight
let python_highlight_all = 1
" ruby
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_rails = 1
augroup vimrc-ruby
autocmd!
autocmd BufNewFile,BufRead *.rb,*.rbw,*.gemspec setlocal filetype=ruby
autocmd FileType ruby set tabstop=2|set shiftwidth=2|set expandtab softtabstop=2
augroup END
let g:tagbar_type_ruby = {
\ 'kinds' : [
\ 'm:modules',
\ 'c:classes',
\ 'd:describes',
\ 'C:contexts',
\ 'f:methods',
\ 'F:singleton methods'
\ ]
\ }
" RSpec.vim mappings
"""""map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
" For ruby refactory
if has('nvim')
runtime! macros/matchit.vim
else
packadd! matchit
endif
" Ruby refactory
nnoremap <leader>rap :RAddParameter<cr>
nnoremap <leader>rcpc :RConvertPostConditional<cr>
nnoremap <leader>rel :RExtractLet<cr>
vnoremap <leader>rec :RExtractConstant<cr>
vnoremap <leader>relv :RExtractLocalVariable<cr>
nnoremap <leader>rit :RInlineTemp<cr>
vnoremap <leader>rrlv :RRenameLocalVariable<cr>
vnoremap <leader>rriv :RRenameInstanceVariable<cr>
vnoremap <leader>rem :RExtractMethod<cr>
" rust
" Vim racer
au FileType rust nmap gd <Plug>(rust-def)
au FileType rust nmap gs <Plug>(rust-def-split)
au FileType rust nmap gx <Plug>(rust-def-vertical)
au FileType rust nmap <leader>gd <Plug>(rust-doc)
au FileType rust setlocal makeprg=make
" Zig
"disable format-on-save from `ziglang/zig.vim`
let g:zig_fmt_autosave = 0
"don't show parse errors in a separate window
let g:zig_fmt_parse_errors = 0
" ZLS uses `zig fmt` as the formatter.
" The Zig FAQ answers some questions about `zig fmt`:
" https://github.com/ziglang/zig/wiki/FAQ
autocmd BufWritePre *.zig lua vim.lsp.buf.format()
if has('nvim')
luafile ~/.vim/vimrc.d/zls.lua
endif
"*****************************************************************************
"*****************************************************************************
"" Include user's local vim config
if filereadable(expand("~/.config/nvim/local_init.vim"))
source ~/.config/nvim/local_init.vim
endif
"*****************************************************************************
"" Convenience variables
"*****************************************************************************