blob: eb98e6190a4d79517f6832354cb034007cc2ec53 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
" ~/.vimrc — Vim 9 configuration
" Requires: vim-plug, rust-analyzer, rg in PATH
let mapleader = ' '
" Use bash for subprocesses — fish has non-interactive startup overhead
let $SHELL = '/bin/bash'
" ── Bootstrap vim-plug ────────────────────────────────────────────────────────
let s:plug_path = expand('~/.vim/autoload/plug.vim')
if !filereadable(s:plug_path)
silent execute '!curl -fLo ' .. s:plug_path .. ' --create-dirs '
\ .. 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" ── Plugins ───────────────────────────────────────────────────────────────────
call plug#begin()
Plug 'yegappan/lsp'
Plug 'vim-fuzzbox/fuzzbox.vim'
Plug 'ghifarit53/tokyonight-vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'tpope/vim-vinegar'
call plug#end()
" ── General settings ──────────────────────────────────────────────────────────
filetype plugin indent on
syntax enable
set number " show line numbers
set signcolumn=yes " always show sign column; prevents layout shift from LSP diagnostics
set updatetime=300 " ms before swap write / CursorHold fires; speeds up LSP diagnostics
set hidden " allow switching away from a modified buffer without saving
set cursorline " highlight the current line the cursor is on
set tabstop=4 " <Tab> displays as 4 spaces
set shiftwidth=4 " >> / << indent by 4 spaces
set softtabstop=4 " <Tab> in insert mode inserts/deletes 4 spaces
set expandtab " insert spaces instead of tab characters
set ignorecase " case-insensitive search by default
set smartcase " override ignorecase when pattern contains uppercase
set incsearch " highlight matches while typing search pattern
set hlsearch " highlight all matches after search
set splitbelow " :split opens new window below
set splitright " :vsplit opens new window to the right
set scrolloff=8 " keep 8 lines of context above/below cursor when scrolling
set clipboard=unnamedplus " yank/put use the system clipboard automatically
set mouse=a " enable mouse support in all modes
" ── File clutter ───────────────────────────────────────────────────────────────
set nobackup
set nowritebackup
let &directory = expand('~/.vim/swap//')
silent! call mkdir(expand('~/.vim/swap'), 'p', 0700)
set undofile
let &undodir = expand('~/.vim/undo//')
silent! call mkdir(expand('~/.vim/undo'), 'p', 0700)
" ── Colors ────────────────────────────────────────────────────────────────────
set termguicolors
let g:tokyonight_style = 'night'
colorscheme tokyonight
" ── LSP (yegappan/lsp) ────────────────────────────────────────────────────────
def LspOnSetup()
var lspServers = [
{
name: 'rust',
filetype: ['rust'],
path: 'rust-analyzer',
args: [],
syncInit: true,
}
]
g:LspAddServer(lspServers)
enddef
augroup MyLsp
autocmd!
autocmd User LspSetup call LspOnSetup()
autocmd FileType rust {
nnoremap <buffer> gd <Cmd>LspGotoDefinition<CR>
nnoremap <buffer> gD <Cmd>LspGotoDeclaration<CR>
nnoremap <buffer> gi <Cmd>LspGotoImpl<CR>
nnoremap <buffer> gr <Cmd>LspShowReferences<CR>
nnoremap <buffer> gy <Cmd>LspGotoTypeDef<CR>
nnoremap <buffer> K <Cmd>LspHover<CR>
nnoremap <buffer> <leader>lr <Cmd>LspRename<CR>
nnoremap <buffer> <leader>la <Cmd>LspCodeAction<CR>
nnoremap <buffer> <leader>lf <Cmd>LspFormat<CR>
nnoremap <buffer> <leader>ld <Cmd>LspDiagShow<CR>
nnoremap <buffer> [d <Cmd>LspDiagPrev<CR>
nnoremap <buffer> ]d <Cmd>LspDiagNext<CR>
nnoremap <buffer> <leader>lo <Cmd>LspOutline<CR>
nnoremap <buffer> <leader>li <Cmd>LspInlayHints toggle<CR>
nnoremap <buffer> <leader>ls <Cmd>LspSymSearch<CR>
}
augroup END
" ── Search ────────────────────────────────────────────────────────────────────
nnoremap <Esc> <Cmd>nohlsearch<CR>
" ── Window navigation ──────────────────────────────────────────────────────────
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" ── Airline ───────────────────────────────────────────────────────────────────
let g:airline_theme = 'tokyonight'
|