-
Notifications
You must be signed in to change notification settings - Fork 0
/
.ideavimrc
153 lines (147 loc) · 5.58 KB
/
.ideavimrc
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
if !has('nvim')
set nocompatible
endif
Plugin 'tpope/vim-commentary'
filetype plugin indent on
if !has('nvim')
set autoindent
set autoread
set backspace=indent,eol,start
set backupdir=~/.vim/backup
set directory=~/.vim/swap//
set encoding=utf-8
set formatoptions=jcroql
set history=10000
set hlsearch
set incsearch
set langnoremap
set laststatus=2
set mouse=a
set nrformats=bin,hex
set sessionoptions=blank,buffers,curdir,folds,help,tabpages,winsize
set smarttab
set tabpagemax=50
set ttyfast
set undodir=~/.vim/undo
set viminfo=!,'100,<50,s10,h
set wildmenu
endif
set breakindent
set cinoptions=j1
set expandtab
set linebreak
set list
if $TERM=~'xterm' || $PRESERVED_TERM=~'xterm'
" `nbsp` is using a common Unicode representation
" Source: https://en.wikipedia.org/w/index.php?title=Whitespace_character&oldid=1122350113#Substitute_images
" `tab` was using it too (the '⪫' character), but while my macOS machine
" renders it correctly, my Linux machine does not
set listchars=tab:▸\ ,trail:█,extends:›,precedes:‹,nbsp:⍽
else
set listchars=tab:\|\ ,trail:#,extends:>,precedes:<,nbsp:!
endif
set number relativenumber
set previewheight=5
set ruler
let s:scrolloff=3
let &scrolloff=s:scrolloff
set shiftwidth=4
if $TERM=~'xterm' || $PRESERVED_TERM=~'xterm'
set showbreak=↪\ "
else
set showbreak=\\\ "
endif
set showcmd
set splitbelow
set splitright
set statusline=[%n]\ %f\ %<%y[%{&ff}]%m%r%w%=%l/%L:%c%V\ \|\ %{strftime(\"%F\ %T\",getftime(expand(\"%:p\")))}
set tabstop=4
set undofile
set nrformats=alpha,bin,hex
set updatetime=250
set ignorecase
set tagcase=followscs
set smartcase
" Delete trailing whitespaces
nnoremap <leader>d<space> :%s/\s\+$//g<enter>
" Yank current filepath and line number to the + register
nnoremap <leader>yf :let @+ = expand("%:p") . ":" . line(".")<enter>
" Expanded version of `gf`:
" Edit existing _or new file_ whose name is under or after the cursor
nnoremap <leader>gf :e <cfile><CR>
" Clear search highlighting
nnoremap <leader>n :noh<CR>
" Insert to do item
nnoremap <leader>iti o<C-D>- [ ]<Space>
" Insert line numbering
xnoremap <leader>iln :!nl -s'. '<CR>gv=
" Convert the current file from `dos` to `unix` fileformat
nnoremap <leader>unix :set fileformat=unix<CR>
" Use arrow keys to jump between buffers
" Source: https://github.com/jdavis/dotfiles/blob/62435dc83dd444be605e9ba204a3033e7192f3e4/.vimrc#L278..L280
map <right> :bn<CR>
map <left> :bp<CR>
" Change `'` to `"` globally in the line
nnoremap <leader>' :s/'/"/g<CR>
" Remove parentheses `()`, (square) brackets `[]`
" or braces (curly brackets) `{}` around an entity, e.g.
" `(foo bar baz)` -> `foo bar baz`
" `[foo bar baz]` -> `foo bar baz`
" `{foo bar baz}` -> `foo bar baz`
nnoremap <leader>d) di("_d%P
nnoremap <leader>d] di["_d%P
nnoremap <leader>d} di{"_d%P
" Source vimrc
nnoremap <leader>ss :source $MYVIMRC<CR>
" Search next/previous WORD, see :help WORD
nnoremap <leader>* yiW/\V<C-r>"<CR>
nnoremap <leader># yiW?\V<C-r>"<CR>
" Run inline `curl` command (HTTP request) and put the output (HTTP response)
" below the command, and reformat the output
" - Supports both single-line and multiline `curl` command
" - Assumes that the response is in JSON format
" - External dependencies: `bash` and `jq`
nnoremap <leader>! vipy}o<CR><CR><ESC>Pvip!bash<CR>]]!!jq<CR>
" IdeaVim-specific mappings
" Equivalent of Vim's `]c`
nnoremap ]c :action VcsShowNextChangeMarker<enter>
" Equivalent of Vim's `[c`
nnoremap [c :action VcsShowPrevChangeMarker<enter>
" Jetbrains IDE does not have equivalents of `<C-w>|`, `<C-w>_` and `<C-w>=`,
" instead it allows to toggle between a maximized current pane (equivalent of
" using both `<C-w>|` and `<C-w>_`) and normalized splits.
"
" `<C-w>m` is unused in Vim, so it seems as a good candidate for that action
" (`m` as in `maximize`)
nnoremap <C-w>m :action MaximizeEditorInSplit<enter>
" Those are not implemented in IdeaVim, so we simulate them
nnoremap <C-w>< :action StretchSplitToLeft<enter>
nnoremap <C-w>> :action StretchSplitToRight<enter>
" Those are not implemented in IdeaVim, so we simulate them, _however_, they
" won't work exactly as in Vim: in Vim, `-` makes the current window smaller,
" `+` makes the current window bigger; in IdeaVim there is no action for that,
" so `-` resizes the current window to bottom, `+` resizes the current window to
" top, which may either make it smaller or bigger depending on the window
" position
nnoremap <C-w>+ :action StretchSplitToTop<enter>
nnoremap <C-w>- :action StretchSplitToBottom<enter>
" Reformat a whole file using `black`; requires `BlackConnect` plugin
" Source: https://plugins.jetbrains.com/plugin/14321-blackconnect
nnoremap <leader>black :action me.lensvol.blackconnect.actions.ReformatWholeFileAction<enter>
" Reformat a selected fragment using `black`; requires `BlackConnect` plugin
" Source: https://plugins.jetbrains.com/plugin/14321-blackconnect
vnoremap <leader>black :action me.lensvol.blackconnect.actions.ReformatSelectedFragmentAction<enter>
" Optimize imports
nnoremap <leader>oi :action OptimizeImports<enter>
" Go to the next error; inspired by the `:cn`
nnoremap <leader>cn :action GotoNextError<CR>
" Go to the previous error; inspired by the `:cp`
nnoremap <leader>cp :action GotoPreviousError<CR>
" Rename object under the cursor
nnoremap <leader>r :action RenameElement<CR>
" Reformat the current paragraph using the PyCharm action; a workaround for
" `gqq` not working in comments
nnoremap <leader>gqq :action FillParagraph<enter>
vnoremap <leader>gq :action FillParagraph<enter>
" Open GitHub Copilot Chat; the mnemonic [o]pen [c]opilot [c]hat
nnoremap <leader>occ :action copilot.chat.show<CR>