Skip to content

Instantly share code, notes, and snippets.

@00sapo
Last active May 24, 2024 15:33
Show Gist options
  • Save 00sapo/b96887c96646762730cacf99a1c4c36d to your computer and use it in GitHub Desktop.
Save 00sapo/b96887c96646762730cacf99a1c4c36d to your computer and use it in GitHub Desktop.
A neovim distribution for data science
" GistID: b96887c96646762730cacf99a1c4c36d
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" README:
" This configuration file is intended for neovim, but most of it should also
" work on vim. It works out of the box with nvim-qt or similar gui and with
" alacritty or other modern terminals.
"
" Installation:
" 1) install neovim with your package manager or by download from
" https://github.com/neovim/neovim/releases/latest
" 2) put this file in ~/.config/nvim/init.vim (unix)
" 3) open neovim and wait for vim-plug being installed
" 4) run :PlugUpdate (maybe you have to restart vim)
" 5) Install (depending on your needs):
" * universal ctags (completion and browsing)
" * dasht (documentation search and view)
" * ripgrep, fd and bat (browsing with Telescope)
" * lazygit (git management - but git is enough)
" * ActivityWatcher
" 7) install all the LSP providers if you plan to use them
" 8) configure your options in the ending part or in prejct specific settings
" (see usage) and appereance (this depends on terminal or gui)
" 8) fonts are configured by your terminal or your gui, nerdfonts are
" supported
"
" Usage:
" * Lsp and Tree-sitter are available, turn on per-project with :LoadLsp and
" :LoadTreeSitter
" * Commands `GlobalConf`, `ProjectConf` and `LoadProjectConf` are available
" to edit configuration files
" * Example of Configuration file at the bottom
" * esc key is mapped to jk, but esc is still available. you can disable it
" with `:inoremap <esc> <nop>`
" * CTRL-w (used for changing window) is remapped to ` (usually used for marks)
" * save with CTRL-s in normal mode
" * <space> opens :Marks to switch to a mark
" * f will wait for a char and then show you all available targets on the
" screen
" * s is like f but with two chars
" * local leader is mapped to ]
" * ]1 search files in the current dir and subdir with Telescope
" * ]2 search git files with Telescope
" * ]3 shows all existing buffers with Telescope
" * ]h will highlight word under cursor with a custom color
" * ]n will clear all hihlighted words
" * ]a is used for autoformat
" * ]g is used to ripgrep in the git project
" * ]t is used to search among project tags
" * ]f finds the current word usages with Telescope
" * \f[textobject] to search [textobject]
" * \ff to start search prompt (see vim-esearch)
" * ]e is used to view errors/warning from linters
" * ]d is used to view docs about a certain word
" * ]c is used to call the LSP code-action
" * = shows tag/symbol definition context; use CTRL+l and CTRL+h to change
" tag definition
" * ctags is running automatically
" * \ev extracts an expression to a variable (not all languages, though...)
" * shift-r to rename objects using LSP, \f to use vim-esearch
" * CTRL+] to follow tag
" * >, and <, are used to move arguments in functions
" * tree-sitter selections:
" * tis : treesitter selection init (current node)
" * ni : node increment
" * si : scope increment
" * nd : node decrement
" * sd : scope decrement
" * if : inner function
" * of : outer function
" * ic : inner conditional
" * oc : outer conditional
" * ip : inner parameter
" * op : outer parameter
" * il : inner loop
" * ol : outer loop
" * [..]
" In your project, you can set
" * if : inner latex frame
" * of : outer latex frame
" * to use autocompletion, you can use arrows or tab/s-tab
" * to expand a snippet, complete it and press ctrl-b
" * to 'surf' between snippet positions use tab
" to change with n and N and apply the same change with .
" * there is vim-surround installed:
" - ys[textobject][typeofsurrounder]
" - cs[oldsurrounder][newsurrounder]
" * ctrl-j ans ctr-k are used to surf errors and warnings in LSP
" * gr and gd are used to go to references and definitions using LSP
" * K uses dasht (install docsets) or LSP if loaded
" * :DD searches on devdocs.io inside your browser
" * ,, to delete the search highlighting
" * ii is a new text object for the indent region in which you are
" * \l calls lazygit
" * CTRL-u u helps you to complete unicode characters
" * CTRL-u d helps you to complete digraphs
" * CTRL-d substitute the previous two characters with the corresponding
" digraph
" * ]u allows to search unicode characters
" * ga shows information for the character under cursor (to use it in Ex
" commands and replacements)
" * Telescope.vim is installed, use it!
" * Other plugins installed, that you should be aware of:
" * LSP-config
" * tree-sitter
" * gist (use github's gist)
" * vim-esearch (fast replace and finder)
" * SudaWrite/SudaRead to read/write as root user
" * Use nvim for simple spreadsheet calculations: vimSum
" * Change nvim configuration on a per-project basis (using `:ProjectConf`,
" both lua and vim supported)
" * ]x 'executes' the program/make e.g.:
" * `restview` for rst documents (install by using '!pip install restview'
" (InstantRst has some issue for me)
" * pandoc slides
" * latex compilation
" * new commands can be set using the `Tmap`
" * you can also use REPL easily: just use ]s or ]S to send text objects (REPL
" is opened automatically, or you can open it by yourself with `Tnew`)
" * file backed-up in ~/.vim/tmp
" * ropevim is installed for refactoring python
" * ctrl-e to move/resize windows
" * alt-h/j/k/l to change windows
" * terminal are always entered in insert mode
" * use scratchpad instead of empty buffer for copying/pasting/remembering
" * open the scratchpad with :Scratch or gs
" * paste the selection into the scratchpad with gs from visual mode
" * clear the scratchpad with gS (normal and visual mode)
" * open scratchpad without leaving current window with \gs
" * persists across sessions
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if empty(glob('~/.local/share/nvim/site/autoload/plug.vim'))
!curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
augroup AuotInstallPlug
au!
au VimEnter * PlugInstall --sync | source $MYVIMRC
augroup END
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
call plug#begin('~/.local/share/nvim/plugged')
""" LOADING ALL THE PLUGINS
" """"""""""""""""""""""""""""""""""
" What vim should provide by default
" """"""""""""""""""""""""""""""""""
Plug 'windwp/nvim-projectconfig'
" Find cursor on move
Plug 'danilamihailov/beacon.nvim'
" Mark pattern
" needed by vim-mark
Plug 'inkarkat/vim-ingo-library'
Plug 'inkarkat/vim-mark'
" Telescope
Plug 'nvim-lua/popup.nvim'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
" Cheatsheet
Plug 'sudormrfbin/cheatsheet.nvim'
" Faster search and replace
Plug 'eugen0329/vim-esearch'
" Accelerated jk
Plug 'rhysd/accelerated-jk'
" repeat plugin commands
Plug 'tpope/vim-repeat'
" Indent text object
Plug 'michaeljsmith/vim-indent-object'
" SudaWrite and SudaRead
Plug 'lambdalisue/suda.vim'
" History tree
Plug 'simnalamburt/vim-mundo'
" highlight target
Plug 'phaazon/hop.nvim'
" Unicode characters
Plug 'chrisbra/unicode.vim'
" popup available commands
Plug 'folke/which-key.nvim'
" """"""""""""""""""""""""""
" Language engines and hints
" """"""""""""""""""""""""""
" Let's set traditional stuffs and then overwrite them
Plug 'sheerun/vim-polyglot'
" Tags
Plug 'ludovicchabant/vim-gutentags'
" Documentation search
Plug 'sunaku/vim-dasht'
Plug 'romainl/vim-devdocs'
" match syntactic start/end
Plug 'andymass/vim-matchup'
" Swap Function Arguments
Plug 'PeterRincker/vim-argumentative'
" Tree-sitter support
Plug 'nvim-treesitter/nvim-treesitter', {'on': [], 'do': ':TSUpdate'}
" Tree-sitter text-object
Plug 'nvim-treesitter/nvim-treesitter-textobjects', {'on': []}
" Rainbow parenthesis using tree-sitter
Plug 'p00f/nvim-ts-rainbow', {'on': []}
" Floating preview for tags
Plug 'weilbith/nvim-floating-tag-preview'
" Neovim LSP
Plug 'neovim/nvim-lspconfig', {'on': []}
" Show light bulb when there are code-actions
Plug 'kosayoda/nvim-lightbulb', {'on': []}
" Make tag stuffs work for LSP (e.g. nvim-floating-tag-preview)
" Plug 'weilbith/nvim-lsp-smag', {'on': []} " breaks floating-tag-preview
" better signature help
Plug 'Shougo/echodoc.vim'
" Completion plugins
Plug 'hrsh7th/nvim-compe'
" auto close parenthesis
Plug 'Raimondi/delimitMate'
Plug '00sapo/vim-endwise', {'branch': 'patch-1'}
" autoformat
Plug 'sbdchd/neoformat'
" Comments
Plug 'tpope/vim-commentary'
" Snippets engine
Plug 'SirVer/ultisnips'
" Snippets are separated from the engine. Add this if you want them:
Plug 'honza/vim-snippets'
" Run commands in the background (Asyncrun breaks vim-surround)
Plug 'tpope/vim-dispatch'
" surround with
Plug 'tpope/vim-surround'
" html tags
Plug 'alvan/vim-closetag'
" extract variable
Plug 'fvictorio/vim-extract-variable'
" grammar
Plug 'rhysd/vim-grammarous'
" Thesaurus
Plug 'Ron89/thesaurus_query.vim'
" """""""""""""""""""
" Buffers and windows
" """""""""""""""""""
" win resizer
Plug 'simeji/winresizer'
" Startify
Plug 'mhinz/vim-startify'
" Better terminal and repls
Plug 'kassio/neoterm'
" Open a scratchpad
Plug 'mtth/scratch.vim'
" Grey out inactive buffers (shade.nvim looks better, but is buggy)
" Plug 'TaDaa/vimade'
" status bar
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" vim diff
Plug 'lambdalisue/vim-unified-diff'
Plug 'rickhowe/diffchar.vim'
Plug 'lambdalisue/vim-improve-diff'
" Preview window to floating window
Plug 'ncm2/float-preview.nvim'
" """
" Git
" """
" Web API (needed for Gist
Plug 'mattn/webapi-vim'
" Gist
Plug 'mattn/gist-vim'
" LazyGit
Plug 'kdheepak/lazygit.nvim'
"
" Git show line changed and stage hunks
Plug 'lewis6991/gitsigns.nvim'
" Easier diff/merge and git management
Plug 'tpope/vim-fugitive'
" """"""""""""""""""
" Language specifics
" """"""""""""""""""
" python (mostly for refactoring until it is not provided by a good
" language server)
Plug 'python-rope/ropevim'
" Better autormat for Julia
Plug 'kdheepak/JuliaFormatter.vim'
" LATEX
Plug 'lervag/vimtex'
" """"""""""
" Appearance
" """"""""""
" Semantic Highlight
Plug 'jaxbot/semantic-highlight.vim'
" Nerd Fonts
Plug 'ryanoasis/vim-devicons'
" Some more colorschemes, use `:Colors`
Plug 'rafi/awesome-vim-colorschemes'
" Indent guideline
Plug 'lukas-reineke/indent-blankline.nvim'
" """""
" Other
" """""
" edit with externallly if firenvim is too much slow
Plug 'raghur/vim-ghost', {'do': ':GhostInstall'}
" ActivityWatcher
Plug 'ActivityWatch/aw-watcher-vim'
" VimSum
Plug 'wgurecky/vimSum'
" Drawing boxes and lines
Plug 'gyim/vim-boxdraw'
" APM (nvim > 0.5)
" until update
" Plug 'polarmutex/vim-apm', {'branch': 'neovim-api-fixes'}
call plug#end()
let maplocalleader = ']'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Beacon
let g:beacon_minimal_jump = 1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Tree-sitter
function! LoadTreeSitterSetup()
call plug#load('nvim-treesitter', 'nvim-treesitter-textobjects', 'nvim-ts-rainbow')
lua <<EOF
require'nvim-treesitter.configs'.setup {
ensure_installed = "maintained", -- one of "all", "maintained" (parsers with maintainers), or a list of languages
highlight = {
enable = true, -- false will disable the whole extension
},
indent = { enable = false },
incremental_selection = {
enable = true,
keymaps = {
init_selection = "tis",
node_incremental = "ni",
scope_incremental = "si",
node_decremental = "nd",
scope_decremental = "sd",
},
},
rainbow = {
enable = true,
extended_mode = true, -- Highlight also non-parentheses delimiters, boolean or table: lang -> boolean
max_file_lines = 2000, -- Do not enable for files with more than 2000 lines, int
},
textobjects = {
select = {
enable = true,
keymaps = {
-- You can use the capture groups defined in textobjects.scm
["of"] = "@function.outer",
["if"] = "@function.inner",
["oc"] = "@class.outer",
["ic"] = "@class.inner",
["ob"] = "@block.outer",
["ib"] = "@block.inner",
-- ["of"] = "@frame.outer",
-- ["if"] = "@frame.inner",
["ol"] = "@loop.outer",
["il"] = "@loop.inner",
["oc"] = "@conditional.outer",
["ic"] = "@conditional.inner",
["op"] = "@parameter.outer",
["ip"] = "@parameter.inner",
},
},
},
matchup = {
enable = true, -- mandatory, false will disable the whole extension
},
}
EOF
set foldmethod=expr
set foldexpr=nvim_treesitter#foldexpr()
nnoremap <localleader>= :TSBufToggle highlight<CR>
let g:indent_blankline_use_treesitter = v:true
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" LSP
function! LoadLspSetup()
call plug#load('nvim-lspconfig', 'nvim-lightbulb')
" call plug#load('nvim-lspconfig', 'nvim-lightbulb', 'nvim-lsp-smag')
nnoremap <silent>gD <cmd>lua vim.lsp.buf.declaration()<CR>
nnoremap <silent>gd <Cmd>lua vim.lsp.buf.definition()<CR>
nnoremap <silent>gdt <cmd>lua vim.lsp.buf.type_definition()<CR>
nnoremap <silent>K <Cmd>lua vim.lsp.buf.hover()<CR>
nnoremap <silent>gi <cmd>lua vim.lsp.buf.implementation()<CR>
nnoremap <silent>gr <cmd>lua vim.lsp.buf.references()<CR>
nnoremap <silent>H <cmd>lua vim.lsp.buf.signature_help()<CR>
nnoremap <silent>R <cmd>lua vim.lsp.buf.rename()<CR>
nnoremap <silent><C-k> <cmd>lua vim.lsp.diagnostic.goto_prev()<CR>
nnoremap <silent><C-j> <cmd>lua vim.lsp.diagnostic.goto_next()<CR>
nnoremap <silent><localleader>c <cmd>lua vim.lsp.buf.code_action()<CR>
nnoremap <silent><localleader>e <cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>
nnoremap <silent><localleader>q <cmd>lua vim.lsp.diagnostic.set_loclist()<CR>
nnoremap <silent><leader>a <cmd>lua vim.lsp.buf.formatting()<CR>
augroup LightBulb
au!
au CursorHold,CursorHoldI * lua require'nvim-lightbulb'.update_lightbulb()
augroup END
endfunction
" nnoremap <silent>, l ocalleader>wa, <cmd>lua vim.lsp.buf.add_workspace_folder()<CR>'
" nnoremap <silent>, l ocalleader>wr, <cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>'
" nnoremap <silent>, l ocalleader>wl, <cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ProjectConfig
command! -bar GlobalConf vs $MYVIMRC
command! -bar ProjectConf lua require("nvim-projectconfig").edit_project_config()
command! -bar LoadProjectConf lua require('nvim-projectconfig').load_project_config()
command! -bar LoadLsp call LoadLspSetup()
command! -bar LoadTreeSitter call LoadTreeSitterSetup()
augroup NvimProjectConfig
autocmd!
autocmd DirChanged,VimEnter * LoadProjectConf
augroup end
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Accelerated jk
nmap j <Plug>(accelerated_jk_gj)
nmap k <Plug>(accelerated_jk_gk)
let g:accelerated_jk_acceleration_table = [4, 8, 12, 16, 20, 24]
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" whichkey
lua << EOF
require("which-key").setup {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
EOF
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Blank line
let g:indent_blankline_show_current_context = v:false
let g:indent_blankline_context_patterns = ['^for', '^while', '^if', '^module', '^mutable', '^quote', 'struct', 'macro', 'function', 'method', 'class']
let g:indent_blankline_filetype_exclude = ['help']
let g:indent_blankline_buftype_exclude = ['terminal']
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Completion
set completeopt=menuone,noselect
let g:compe = {}
let g:compe.enabled = v:true
let g:compe.autocomplete = v:true
let g:compe.debug = v:false
let g:compe.min_length = 1
let g:compe.preselect = 'enable'
let g:compe.throttle_time = 80
let g:compe.source_timeout = 200
let g:compe.resolve_timeout = 800
let g:compe.incomplete_delay = 400
let g:compe.max_abbr_width = 100
let g:compe.max_kind_width = 100
let g:compe.max_menu_width = 100
let g:compe.documentation = v:true
" see :h compe-source
let g:compe.source = {
\ 'omni': {
\ 'filetypes': ['tex'],
\ }
\}
let g:compe.source.path = v:true
let g:compe.source.tags = v:true
let g:compe.source.buffer = v:true
let g:compe.source.nvim_lsp = v:true
let g:compe.source.ultisnips = v:true
let g:compe.source.emoji = v:true
call compe#setup(g:compe)
function! s:solve_complete_endwise_conflict()
if pumvisible()
if complete_info()["selected"] >= 0
return "\<C-\>"
else
return "\<C-e>\<CR>"
endif
else
return "\<CR>"
endif
endfunction
inoremap <expr><CR> s:solve_complete_endwise_conflict()
inoremap <silent><expr><C-Space> compe#complete()
inoremap <silent><expr><C-e> compe#close('<C-e>')
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<TAB>"
" Floating preview for docs
let g:float_preview#docked = 0
" Snippets
let g:UltiSnipsExpandTrigger='<c-b>'
let g:UltiSnipsJumpForwardTrigger='<tab>'
let g:UltiSnipsJumpBackwardTrigger='<s-tab>'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" echodoc
let g:echodoc#enable_at_startup = 1
let g:echodoc#type = 'virtual'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Dasht
nnoremap <silent>K :Dasht <C-r><C-w><CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Preview tag on hold
let g:floating_tag_preview_highlight_tag_word = v:false
let g:floating_tag_preview_auto_closing_events = [
\ 'InsertEnter', 'WinNew', 'WinEnter', 'BufEnter', 'BufNew', 'CursorMoved', 'WinScrolled']
nnoremap <C-l> :Ptnext<CR>
nnoremap <C-h> :Ptprevious<CR>
nnoremap = :Ptag <C-r><C-w><CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Indentation
let g:indentLine_char = '▏'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Autoformat
vmap <localleader>a :Neoformat<CR>
nmap <localleader>a :Neoformat<CR>
" Enable alignment
let g:neoformat_basic_format_align = 1
" Enable tab to spaces conversion
let g:neoformat_basic_format_retab = 1
" Enable trimmming of trailing whitespace
let g:neoformat_basic_format_trim = 1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Unicode Characters
nnoremap <localleader>u :call unicode#Fuzzy()<CR>
inoremap <C-d> <esc>vh:<C-U>call unicode#GetDigraph(visualmode(), 1)<CR>a
nnoremap ga :UnicodeName<CR>
imap <C-u>u <Plug>(UnicodeComplete)
imap <C-u>d <Plug>(DigraphComplete)
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Gutentags
" ignore hidden files or directory when creating tags
let g:gutentags_ctags_exclude = ['.venv', '.mypy_cache', '.git']
let g:gutentags_project_root = ['.gutentags']
let g:gutentags_modules = ['ctags']
" let g:gutentags_cache_dir = expand('~/.cache/nvim/ctags/')
let g:gutentags_generate_on_new = 1
let g:gutentags_generate_on_missing = 1
let g:gutentags_generate_on_write = 1
let g:gutentags_generate_on_empty_buffer = 0
let g:gutentags_ctags_extra_args = [
\ '--fields=+ailmnS',
\ ]
" \ '--tag-relative=yes',
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Semantic Highlight
" the enables semantic highlight on the keys filetypes and cursorhold update
" on the corresponding extensions
let g:semanticEnableFileTypes = {
\ 'javascript': 'js',
\ 'vim': 'vim',
\ 'python': 'py',
\ 'c': 'c',
\ 'cpp': 'cpp',
\ 'java': 'java',
\ 'julia': 'jl',
\ 'r': 'r',
\ 'matlab': 'm',
\ 'lua': 'lua'
\ }
let g:semanticUseCache=1
let g:semanticPersistCache=1
" let g:semanticEnableBlacklist=0
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Telescope
" mappings
nnoremap <localleader>1 <cmd>Telescope file_browser<cr>
nnoremap <localleader>2 <cmd>Telescope git_files<cr>
nnoremap <localleader>3 <cmd>Telescope buffers<cr>
nnoremap <localleader>f <cmd>Telescope grep_string<cr>
nnoremap <localleader>g <cmd>Telescope live_grep<cr>
nnoremap <localleader>t <cmd>Telescope tags<cr>
nnoremap <localleader>r <cmd>Telescope registers<cr>
nnoremap <localleader>q <cmd>Telescope quickfix<cr>
nnoremap <localleader>l <cmd>Telescope loclist<cr>
nnoremap <space> <cmd>Telescope marks<cr>
lua << EOF
require("telescope").setup {
pickers = {
git_files = {
show_untracked=false,
recurse_submodules=true
},
tags = {
show_line = true
},
buffers = {
show_all_buffers = true,
sort_lastused = false,
-- theme = "dropdown",
-- previewer = true,
mappings = {
i = {
["<c-d>"] = require("telescope.actions").delete_buffer,
},
n = {
["<c-d>"] = require("telescope.actions").delete_buffer,
}
}
}
}
}
EOF
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" vim-esearch
let g:esearch = {}
" Start the search only when the enter is hit instead of updating the pattern while you're typing.
let g:esearch.live_update = 0
" Open the search window in a vertical split and reuse it for all further searches.
let g:esearch.name = '[esearch]'
let g:esearch.win_new = {esearch -> esearch#buf#goto_or_open(esearch.name, 'tabnew')}
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vimtex
function RemoteCompiler()
if empty(v:servername) && exists('*remote_startserver')
call remote_startserver('VIM')
endif
endfunction
augroup VimTex
au!
au FIleType tex setlocal spell spelllang=en_us
au FIleType tex set tw=80
au FIleType tex :call RemoteCompiler()
au FIleType tex :VimtexTocOpen
augroup END
let g:tex_flavor = 'latex'
let g:vimtex_fold_enabled = 1
let g:vimtex_view_general_viewer = 'okular'
let g:vimtex_view_general_options = '--unique file:@pdf\#src:@line@tex'
let g:vimtex_view_general_options_latexmk = '--unique'
let g:vimtex_quickfix_open_on_warning = 0
let g:vimtex_compiler_latexmk = {'build_dir': 'build'}
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" LanguageTool / spell checcker
let g:grammarous#default_comments_only_filetypes = {
\ '*' : 1, 'help' : 0, 'markdown' : 0,
\ }
let g:grammarous#use_vim_spelllang = 1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" status bar
let g:airline_powerline_fonts = 1
let g:airline#parts#ffenc#skip_expected_string='utf-8[unix]'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Mark pattern
vmap <localleader>h <Plug>MarkSet
vmap <localleader>n <Plug>MarkClear
nmap <localleader>h <Plug>MarkSet
nmap <localleader>n <Plug>MarkClear
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Neoterm
nmap <localleader>ss <Plug>(neoterm-repl-send-line)
nmap <localleader>s <Plug>(neoterm-repl-send)
vmap <localleader>s <Plug>(neoterm-repl-send)
nmap <localleader>S s$
" Executes commands in a terminal
let g:neoterm_automap_keys = '<localleader>x'
set scrollback=10000
autocmd WinEnter term://* startinsert
autocmd WinLeave term://* stopinsert
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Hop
nmap s :HopChar2<CR>
nmap f :HopChar1<CR>
nmap -= :HopWord<CR>
nmap -- :HopPattern<CR>
vmap s <cmd>HopChar2<CR>
vmap f <cmd>HopChar1<CR>
vmap -= <cmd>HopWord<CR>
vmap -- <cmd>HopPattern<CR>
lua require'hop'.setup()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Startify
let g:startify_change_to_dir = 1
let g:startify_change_to_vcs_root = 1
let g:startify_change_cmd = 'cd'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Gitsigns
lua require'gitsigns'.setup()
" Scratchpad
let g:scratch_autohide = 1
let g:scratch_insert_autohide = 0
map <leader>gs :ScratchPreview<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" " Vimade (fade out inactive windows)
" let g:vimade = {
" \ "fadelevel": 0.5,
" \ }
" nnoremap <leader>s :VimadeToggle<CR>
" nnoremap <C-Up> :let g:vimade.fadelevel += 0.1<CR>
" nnoremap <C-Down> :let g:vimade.fadelevel -= 0.1<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" LazyGit
nmap <Leader>l :LazyGit<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ActivityWatcher
augroup ActivityWatcher
au!
au VimEnter * :AWStart
augroup END
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" LANGUAGE SPECIFIC SETTINGS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Julia
" formatting
let g:JuliaFormatter_always_launch_server = 1
let g:JuliaFormatter_options = {'style' : 'blue'}
" use precompiled package: go to the plugin directory and run
" julia -project scripts/packagecompiler.jl
let g:JuliaFormatter_use_sysimage=1
augroup Julia
au!
au FIleType julia set tw=80
" formatting
au FIleType julia nnoremap <buffer> <localleader>a :JuliaFormatterFormat<CR>
au FIleType julia vnoremap <buffer> <localleader>a :JuliaFormatterFormat<CR>
augroup END
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" MATLAB
let g:matlab_vimlab_vertical=1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" GENERIC
" case insensitive search by default
set ignorecase
" changing escape to jk
inoremap jk <esc>
tnoremap jk <C-\><C-n>
" clear highlighting on press jk or ,,
noremap ,, <esc>:noh<return>jk
inoremap jk <esc>:noh<return>jk
set backspace=indent,eol,start
" ctrl-w -> `
noremap ` <C-w>
" ctrl-w changes window even in insert mode
imap <C-w> <C-o><C-w>
" <alt-h/j/k/l> changes windows
nmap <silent> <A-k> :wincmd k<CR>
nmap <silent> <A-j> :wincmd j<CR>
nmap <silent> <A-h> :wincmd h<CR>
nmap <silent> <A-l> :wincmd l<CR>
imap <silent> <A-k> jk:wincmd k<CR>
imap <silent> <A-j> jk:wincmd j<CR>
imap <silent> <A-h> jk:wincmd h<CR>
imap <silent> <A-l> jk:wincmd l<CR>
" tmap <silent> <A-k> jk:wincmd k<CR>
" tmap <silent> <A-j> jk:wincmd j<CR>
" tmap <silent> <A-h> jk:wincmd h<CR>
" tmap <silent> <A-l> jk:wincmd l<CR>
" save with ctrl-s
nnoremap <C-s> :w<CR>
inoremap <C-s> <esc>:w<CR>
" Live substituting
set inccommand=nosplit
set wildmenu
set wildmode=longest,list
" set nocompatible
set relativenumber
filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab
" enable folding
set foldlevel=99
" The following is to use from eviroment clipboard
set clipboard=unnamedplus
" set modeline to use first line to detect filetype
set modeline
" cursor configuration
let &t_SI = "\<Esc>[6 q"
let &t_SR = "\<Esc>[4 q"
let &t_EI = "\<Esc>[2 q"
" Remember history
set undodir=~/.vim/undodir
set undofile
set backupdir=$HOME/.vim/tmp
set backup
set encoding=utf8
" Highlight yanked regions
augroup HighlightYank
autocmd!
au TextYankPost * silent! lua vim.highlight.on_yank{timeout=250}
augroup END
" cursors
augroup Cursors
au!
" au VimEnter,WinEnter,BufWinEnter * setlocal cursorcolumn
" au WinLeave * setlocal nocursorcolumn
au VimEnter,WinEnter,BufWinEnter * setlocal cursorline
au WinLeave * setlocal nocursorline
augroup END
" split bar (remove it)
augroup SplitLine
au!
au WinNew * :hi VertSplit guibg=bg guifg=bg
augroup END
augroup Terminal
au!
autocmd TermOpen * set bufhidden=hide
augroup END
command! -bar -bang Marks call Telescope#vim#marks(<bang>0)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" CUSTOM OPTIONS
" Font
" the font (for gui)
set guifont=DejavuSansMono\ Nerd\ Font\ Mono:h14:b
"""""""""""""""""
" COLOR SCHEME
set t_Co=256 " This is may or may not needed.
set termguicolors " enable true colors support
function! SetTheme(use_dark)
if !a:use_dark
"""""""""""""""""
" LIGHT THEME
colorscheme onehalflight
" SemanticHighLight light colors
let g:semanticGUIColors = ['#632708', '#0A05E2', '#06839A', '#CA2D80', '#148A29', '#1A2E7F', '#76680A', '#2B625A', '#8013CA', '#094DDC', '#4B0E3C', '#6648CF', '#0983E4', '#C53941', '#15500E', '#2165B1', '#441578', '#110F92', '#704D8D', '#155B7E', '#0A7551', '#7F4F64', '#A21799', '#4A5A3A', '#775219', '#B25542', '#122AD7', '#05944D', '#B80D2B', '#0B8079', '#D12700', '#471FE3', '#3A5ED8', '#8B44B9', '#2C790E', '#682029', '#4E5690', '#99448A', '#6855B6', '#1078B5', '#B7120F', '#3F51AF', '#765549', '#282E14', '#A1476B', '#A80F53', '#4A50E4', '#485A0F', '#741D76', '#2C7539', '#37119C', '#1263C9', '#7A45A0', '#62158B', '#7A3AD2', '#BF481A', '#115C3D', '#831649', '#7313A7', '#275993', '#AE3FC4', '#3B319B', '#BA19B7', '#B23EA1', '#9C5A0C', '#157399', '#2D2BC1', '#1A4317', '#1B4834', '#4F6D0B', '#BB3A73', '#2E1667', '#891B0D', '#1E6C6D', '#571A5B', '#406029', '#173DA4', '#A70A69', '#945153', '#6B3D6E', '#810E24', '#1729A3', '#5815C7', '#2C751F', '#130BAC', '#A32747', '#494094', '#411E0E', '#4E2BC1', '#141884', '#7B5A32', '#301085', '#5C3AA8', '#1B44CB', '#134EAE', '#42360D', '#A14F16', '#1F689B', '#641C37', '#4C5223', '#4D53C9', '#3732B0', '#386850', '#2324D9', '#4357A1', '#1B6A5A', '#0C8247', '#8F3F4E', '#A51282', '#1B6B7D', '#755E0F', '#4C1211', '#2511CB', '#1429B9', '#135D2D', '#5F5819', '#C1402C', '#3F6740', '#0E77D1', '#884020', '#804038', '#2B6AE0', '#5A3F2F', '#476D21', '#0734CE', '#8A2F26', '#595F4B', '#15671B', '#0C7419', '#237C5B']
let g:semanticTermColors = ['52', '20', '30', '162', '28', '18', '94', '239', '92', '26', '53', '62', '32', '167', '22', '25', '54', '18', '60', '24', '29', '95', '126', '239', '94', '131', '20', '29', '124', '30', '160', '56', '62', '97', '28', '52', '60', '96', '61', '31', '124', '61', '95', '235', '131', '125', '62', '58', '90', '238', '55', '26', '97', '54', '98', '130', '23', '89', '55', '24', '134', '60', '127', '133', '130', '24', '19', '235', '236', '58', '131', '17', '88', '23', '53', '238', '25', '125', '95', '59', '88', '19', '56', '28', '19', '125', '60', '235', '55', '18', '95', '54', '61', '26', '25', '236', '130', '24', '53', '238', '62', '61', '239', '20', '61', '23', '29', '95', '126', '24', '94', '52', '20', '19', '22', '58', '130', '239', '32', '94', '95', '26', '238', '58', '26', '88', '240', '22', '28', '29']
" Bat theme for Telescope preview
let $BAT_THEME = "Monokai Extended Light"
let g:airline_theme='sol'
" change cursor colors
" hi CursorLine guibg=#f2f2f2 guifg=None
hi ColorColumn guibg=#f2f2f2 guifg=None
else
"""""""""""""""""
" DARK THEME
colorscheme one
" then: LazyGitConfig -> change theme
" then: LazyGitConfig -> change theme
let g:airline_theme='onedark'
endif
endfunction
"""""""""""""""""
" the color for cursor animation
" put this last otherwise it may not work
hi Beacon guibg=green
augroup TmapExecutes
au!
" Pandoc slides
au BufEnter *.md Tmap pandoc --to revealjs --output %.html --self-contained %; firefox %.html
" Restview
au BufEnter *.rst Tmap restview %
" Latex
au BufEnter *.tex nmap <buffer> <localleader>x :VimtexCompile<CR>
augroup END
" shell
set shell=/bin/fish
let g:use_dark = v:false
LoadProjectConf
call SetTheme(g:use_dark)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" project configuration example
" " enable tree-sitter
" LoadTreeSitter
"
" " enable lsp
" LoadLsp
" lua <<EOF
" lsp = require('lspconfig')
" lsp.julials.setup{}
" lsp.pylsp.setup{}
" EOF
" LspStart
"
" " disable tag-completion
" let g:compe.source.tags = v:false
" call compe#setup(g:compe)
"
" " set light theme
" let g:use_dark = v:false
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" .tmux.conf example
"
" unbind-key C-b
" set -g prefix `
" bind-key ` send-prefix
" set-option -sg escape-time 10
" set-option -g default-terminal "screen-256color"
" set-option -sa terminal-overrides ',XXX:RGB'
" bind -n M-h select-pane -L
" bind -n M-j select-pane -D
" bind -n M-k select-pane -U
" bind -n M-l select-pane -R
@00sapo
Copy link
Author

00sapo commented Aug 12, 2021

immagine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment