Created
April 28, 2026 14:21
-
-
Save sieste/9c9d2c2a0b80377a087891f3d8d3c626 to your computer and use it in GitHub Desktop.
init.vim
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| " standard key bindings | |
| inoremap jk <Esc> | |
| nnoremap <Space> : | |
| nnoremap <Enter> gwap | |
| vnoremap <Enter> gw | |
| " paste/yank from/to system clipboard | |
| set clipboard+=unnamedplus | |
| nnoremap <leader>p "+p | |
| vnoremap <leader>y "+y | |
| " reformat, redraw, clear search pattern with Ctrl+/ | |
| " (NOTE: <C-_> maps to Ctrl+/) | |
| nnoremap <silent> <C-_> :mode<enter>:nohl<enter> | |
| " compile | |
| nnoremap <silent> = :!pdflatex %<enter><enter> | |
| " buffers | |
| set hidden " buffers become hidden when abanoned | |
| " next/prev/lastopen buffer | |
| nnoremap <C-H> :bprev<CR> | |
| nnoremap <C-L> :bnext<CR> | |
| nnoremap <C-J> :b#<CR> | |
| nnoremap <C-K> :buffers<CR>:buffer<Space> | |
| " automatically source any .nvim.lua found in current working directory | |
| set exrc | |
| " " lua commands | |
| lua <<EOF | |
| local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" | |
| if not vim.loop.fs_stat(lazypath) then | |
| vim.fn.system({ | |
| "git", | |
| "clone", | |
| "--filter=blob:none", | |
| "https://github.com/folke/lazy.nvim.git", | |
| lazypath, | |
| }) | |
| end | |
| vim.opt.rtp:prepend(lazypath) | |
| require("lazy").setup({ | |
| -- codecompanion | |
| { | |
| "olimorris/codecompanion.nvim", | |
| version = "^18.0.0", | |
| dependencies = { | |
| "nvim-lua/plenary.nvim", | |
| "nvim-treesitter/nvim-treesitter", | |
| }, | |
| opts = { | |
| interactions = { | |
| chat = { | |
| adapter = "ollama", | |
| -- model = "llama3.2:3b" | |
| model = "qwen2.5-coder:7b" | |
| }, | |
| inline = { | |
| adapter = "ollama", | |
| -- model = "llama3.2:3b" | |
| model = "qwen2.5-coder:7b" | |
| }, | |
| }, | |
| -- NOTE: The log_level is in `opts.opts` | |
| opts = { | |
| log_level = "DEBUG", | |
| }, | |
| }, | |
| }, | |
| -- vim-slime | |
| { | |
| "jpalardy/vim-slime", | |
| init = function() | |
| vim.g.slime_target = "tmux" | |
| vim.g.slime_default_config = { socket_name = "default", target_pane = "{marked}" } | |
| vim.g.slime_dont_ask_default = 1 | |
| vim.g.slime_paste_file = vim.fn.tempname() | |
| vim.g.slime_python_ipython = 1 | |
| end, | |
| }, | |
| -- buftabline | |
| { "ap/vim-buftabline" }, | |
| -- ripgrep helper | |
| { "jremmen/vim-ripgrep" } | |
| }) | |
| vim.keymap.set("n", "<C-c><C-c>", "<Cmd>SlimeSendCurrentLine<CR>j", { silent = true }) | |
| vim.keymap.set("x", "<C-c><C-c>", "<Plug>SlimeRegionSend", { silent = true }) | |
| vim.keymap.set("n", "<C-c><C-x>", "<Cmd>SlimeSend1 \x11\x03<CR>") | |
| EOF | |
| " use ripgrep (smart case, vimgrep compatible output) | |
| if executable('rg') | |
| set grepprg=rg\ -S\ --color=never\ --vimgrep | |
| endif | |
| set grepformat=%f:%l:%m | |
| " " install plugins with vim-plug, do :PlugInstall after adding new plugins | |
| " call plug#begin('~/.config/nvim/plugged') | |
| " " slime: send text to tmux pane | |
| " Plug 'jpalardy/vim-slime' | |
| " " buffers in tab line | |
| " Plug 'ap/vim-buftabline' | |
| " " ripgrep | |
| " Plug 'jremmen/vim-ripgrep' | |
| " " " | |
| " " " julia support | |
| " " Plug 'JuliaEditorSupport/julia-vim' | |
| " " " neorg (nvim org mode https://github.com/nvim-neorg | |
| " " Plug 'nvim-neorg/neorg', {'branch': 'main'} | Plug 'nvim-lua/plenary.nvim' | |
| " " " Tree sitter syntax highlighting and code parsing | |
| " " Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} " We recommend updating the parsers on update | |
| " " Plug 'vlime/vlime', {'rtp': 'vim/'} " common lisp REPL | |
| " " Plug 'zah/nim.vim' " nim syntax highlighting | |
| " " Plug 'eraserhd/parinfer-rust' | |
| " " Plug 'neovim/nvim-lspconfig' " enable LSP | |
| " " Plug 'williamboman/mason.nvim', {'branch': 'main'} " another packager for LSP, linters etc | |
| " " Plug 'godlygeek/tabular' | |
| " call plug#end() | |
| " | |
| " | |
| " " vim slime: Control-cc to send current line to marked pane (C-b m) | |
| " let g:slime_target = 'tmux' | |
| " let g:slime_default_config = {"socket_name": "default", "target_pane": "{marked}"} | |
| " let g:slime_dont_ask_default = 1 | |
| " let g:slime_paste_file = tempname() | |
| " let g:slime_python_ipython = 1 " enables %cpaste in ipython | |
| " nmap <silent> <c-c><c-c> :SlimeSendCurrentLine<Enter>j | |
| " xmap <silent> <c-c><c-c> <Plug>SlimeRegionSend | |
| " " in insert mode do <C-q><C-c> to insert the special character ^C | |
| " nmap <c-c><c-x> :SlimeSend1 <CR> | |
| " xmap <c-c><c-v> :call slime#send('args(' . @* . ')') | |
| " | |
| " | |
| " func! Str() | |
| " let l:mod = mode() | |
| " if l:mod == 'n' | |
| " normal viw"xy | |
| " elseif l:mod == 'v' || l:mod == 'V' | |
| " normal gv"xy | |
| " else | |
| " return | |
| " endif | |
| " let l:result = getreg("x") | |
| " return "str(" . l:result . ", max.level=2) | |
| " | |
| " endfunc | |
| " xmap <c-c><c-v> :call slime#send(Str())<enter> | |
| " nmap <c-c><c-v> :call slime#send(Str())<enter> | |
| " | |
| " | |
| " | |
| " | |
| " TAB behavior for different filetypes | |
| autocmd Filetype r setlocal ts=2 sw=2 expandtab | |
| " no autoindent | |
| autocmd Filetype * setlocal noautoindent nocindent nosmartindent indentexpr= | |
| " | |
| " " smart alt-enter in insert mode: jump to unclosed parenthesis or previous | |
| " " indentation level | |
| " function! EnterToParenOrIndent() | |
| " let l:li = getline('.') | |
| " let l:pos = 0 | |
| " execute "normal! a\<Cr>" | |
| " if l:li =~ '([^)]*$' | |
| " let l:pos = stridx(l:li, '(') + 1 | |
| " elseif l:li =~ '^[ ]\+' | |
| " let l:pos = match(l:li, '\S') | |
| " endif | |
| " if l:pos > 0 | |
| " for i in range(l:pos) | |
| " execute "normal! a\<Space>" | |
| " endfor | |
| " endif | |
| " endfunction | |
| " | |
| " inoremap <M-CR> <Esc>:call EnterToParenOrIndent()<CR>a | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment