init.vim 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972
  1. " vim:fileencoding=utf-8:foldmethod=marker:foldmarker={{{,}}}
  2. " zo command for open fold
  3. " zc command for close fold
  4. " !!! - fold colors modified in colorscheme files !!!
  5. " {{{ Basic VIM settings
  6. " Enable line numbering
  7. :set number
  8. " make numbering relative
  9. :set relativenumber
  10. " For example - scrolloff=7
  11. " When cursor on 7 line, counting from bottom, and U going to next line,
  12. " document
  13. " Default value = 0
  14. :set scrolloff=4
  15. " Copying indents from prev line when adding new
  16. :set autoindent
  17. " Supplements option above by adding spaces in ((needed)) places
  18. :set smartindent
  19. " price of tab (in spaces)
  20. :set tabstop=3
  21. " By default - adjusting the indentation width (in spaces) adding by commands
  22. " >> and <<. If != tabstop, then indent can consist both of spaces and tabs.
  23. " When smarttab is on, may have an additional impact
  24. " (0 for ‘tabstop’):
  25. :set shiftwidth=0
  26. " Pressing tab in BoL (before 1-st not-space symbol) adding indent == shiftwidth
  27. " Backspace deleting entire indent, not just one tab
  28. :set smarttab
  29. " Count of spaces the tab is displayed with when added
  30. " For example - tabstop=8 ; softtabstop=4
  31. " Example - Triple tab. We have - 1 tab (8 spaces) and 4 spaces
  32. " (0 for ‘tabstop’, -1 for ‘shiftwidth’):
  33. :set softtabstop=-1
  34. " activating mouse in VIM
  35. ":set mouse=a
  36. " autotips on type
  37. :set encoding=UTF-8
  38. " Not change tabs by spaces
  39. :set noexpandtab
  40. " Show tabs as chars
  41. :set list
  42. ":set listchars=tab:
  43. ":set listchars=tab:\
  44. :set listchars=tab:\
  45. " for show by :echo mapleader (i saved default key)
  46. :let mapleader = "\\"
  47. " Use system clipboard in nvim
  48. :set clipboard+=unnamedplus
  49. " Number of screen lines to use for the command-line
  50. :set cmdheight=1
  51. " comma-separated list of strings that can start a comment line
  52. ":set comments="s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-,fb:•"
  53. " Comma-separatef list of completion options
  54. " Available
  55. " menu, menuone, longest, preview, noinsert, noselect
  56. :set completeopt="menu"
  57. " Comma-separated list of languages. Vim will use the first language for which
  58. " the desired help can be found. English help will alway be used as a last
  59. " resort.
  60. :set helplang=ru,en
  61. " Ignore case in search patterns
  62. ":set ignorecase
  63. " Not Ignore case
  64. :set noignorecase
  65. " colored column, for your orientation (may be U don't want write line > 80 symbols
  66. ":set colorcolumn=80
  67. " settings for nvim-highlight-colors
  68. :set termguicolors
  69. :set t_Co=256
  70. " enable folding
  71. " marker "{\{{" (without "\" sign) increases fold level by 1
  72. " marker "}\}}" (without "\" sign) decreases fold level by 1
  73. " it works in comments
  74. " for enter to fold - use zo command
  75. ":set foldmethod=syntax
  76. :set foldmethod=syntax
  77. let g:python_recommended_style = 1
  78. " {{{Function for python folding
  79. :function! Python_Folding()
  80. "return match(getline(v:lnum), '\S')
  81. let curtabnum = match(getline(v:lnum), '\S')
  82. let nexttabnum = match(getline(v:lnum), '\S')
  83. if curtabnum == 0
  84. return 0
  85. elseif curtabnum > nexttabnum
  86. return "<".curtabnum
  87. elseif curtabnum == nexttabnum
  88. return curtabnum
  89. else
  90. return ">".curtabnum
  91. endif
  92. ":set foldmethod=indent
  93. " Достаточно хуёво работающие fold на основе табов (не создаёт новые уровни
  94. " fold'ов)
  95. ":set foldexpr=getline(v:lnum)[0]==\"\\t\"
  96. " Самый рабочий код, но нуждается в доработке
  97. " let thisline = getline(v:lnum)
  98. " "let tabcount = len(thisline) - len(replace(thisline, "\t", ""))
  99. " let tabcount = match(thisline, '\S')
  100. " let prevline = ""
  101. " if v:lnum == 0
  102. " prevline = ""
  103. " else
  104. " let prevline = getline(v:lnum - 1)
  105. " endif
  106. " let prevtabcount = match(prevline, '\S')
  107. " let nextline = getline(v:lnum + 1)
  108. " let nexttabcount = match(nextline, '\S')
  109. "
  110. " if tabcount < nexttabcount
  111. " return ">".nexttabcount
  112. " elseif tabcount > nexttabcount
  113. " return "<".tabcount
  114. " else
  115. " return tabcount
  116. " endif
  117. :endfunction
  118. " }}}
  119. "autocmd FileType python set foldmethod=indent
  120. "autocmd FileType python call Python_Folding()
  121. "autocmd FileType python set foldexpr=Python_Folding()
  122. "autocmd FileType python set foldmethod=expr
  123. "autocmd FileType python set foldexpr=Python_Folding()
  124. "autocmd BufEnter *.py set foldmethod=expr
  125. " left to comma marker opens fold, and right to comma closes it
  126. " more then 1 pair of strings is unsupported
  127. " for example
  128. " if U write
  129. ":set foldmarker={{{,}}},(((,)))
  130. " that's won't work.
  131. " For this use
  132. ":set foldmethod=expr
  133. ":set foldmarker={{{,}}}
  134. " color sheme from awesome-vim-colorschemes plugin
  135. " space-vim-dark;
  136. source ~/.local/share/nvim/plugged/awesome-vim-colorschemes/colors/space-vim-dark.vim
  137. " }}}
  138. " {{{ Plugins usage descriptions
  139. " {{{ coc.nvim
  140. " Install coc.nvim
  141. " https://github.com/neoclide/coc.nvim
  142. " 1. install yarn
  143. " 2. install coc.nvim plugin
  144. " 3. :CocInstall [coc extension]
  145. " 4. :CocConfig - for access to config
  146. " }}}
  147. " {{{ coc marketplace
  148. " Coc marketplace - list all available extensions
  149. " usage
  150. ":CocList marketplace - list all available extensions
  151. ":Coclist marketplace python - search extension that name contains python
  152. "[Tab], when on extension - doing install, uninstall and homepage actions
  153. " }}}
  154. " {{{ Plugins (un)installation
  155. " install plugins
  156. " 1. install vim-plug
  157. " https://github.com/junegunn/vim-plug
  158. " 2. write call plug#begin() and call plug#end()
  159. " 3. between them write "Plug 'link'"
  160. " 4. re-enter to init.vim
  161. " 5. Write command ":PlugInstall"
  162. " 6. Done
  163. "
  164. " Uninstall plugins (what is unlisted in plugin list)
  165. ":PlugClean
  166. " Update plugins
  167. ":PlugUpdate
  168. " Update vim-plug itself
  169. ":PlugUpgrade
  170. " }}}
  171. " {{{ NERDTree commands
  172. " NERDTree commands (:help NERDTree for more)
  173. "I - toggle hidden files displayed
  174. "X - Recursively close dir
  175. "O - recursively open dir
  176. "A - Zoom (max/min) the NERDTree window
  177. "? - Quick help
  178. " }}}
  179. " {{{ vim-surround
  180. " vim-surround
  181. " usage (when inside brackets/etc)
  182. " change " to '
  183. "cs"'
  184. " change " to <q>
  185. "cs"<q>
  186. " change any tag to "
  187. "cst"
  188. " remove delimiter
  189. "ds"
  190. " close word with "
  191. "ysiw"
  192. " close word with [] and add space between word and brakets
  193. "ysiw[
  194. " close word with [] without space
  195. "ysiw]
  196. " close entire line with "
  197. "yss"
  198. " close entire line(s) in tag (also works with visual mode)
  199. "V -> highlight lines -> S<p class="important">
  200. " }}}
  201. " {{{ vim-multiple-cursors
  202. " vim-multiple-cursors
  203. " WARNING!
  204. " Undo and Redo doesn't work with this plugin!
  205. " usage
  206. " for choose same words in document
  207. " 1. Command - fp<C-n> (in command mode press fp, then Ctrl+n)
  208. " 2. Highlight all the word, if it doesn't happened
  209. " 3. Press <C-n> for add new cursor to same word
  210. " 4. Command - c
  211. " 5. Change the text
  212. "
  213. " For add a cursor to each line of visual selection
  214. " 1. Command - vip<C-n>
  215. " 2. Command for insert- i
  216. " 2* - other VIM commands works too (e.g A, hjkl, etc.)
  217. " }}}
  218. " {{{ Tagbar
  219. " Tagbar
  220. " requirments:
  221. " Exuberant Ctags/Universal Ctags ; phpctags (for php) ; jsctags (for JavaScript) ; etc-ctags
  222. " Universal Ctags
  223. " https://github.com/universal-ctags/ctags
  224. " todo-comments
  225. " requirments - writed near Plug'' line
  226. " commands
  227. " * all the commands accept next arguments:
  228. """ Specify the directory to search for comments
  229. " cwd=~/projects/foobar
  230. """ Comma separated list of keywords to filter results by. Case-sensitive
  231. " keywords=TODO,FIX
  232. ":TodoQuickFix - shows all todos in project by QuickFix list
  233. ":TodoLocList - same but uses the location list
  234. ":TodoTrouble - same but uses Trouble
  235. ":TodoTelescope - same but uses Telescope
  236. " }}}
  237. " {{{ nvim-notify
  238. " show notify manually
  239. ":lua vim.notify("error test", "error")
  240. " }}}
  241. " {{{ GuessIndent
  242. " manually trigger
  243. ":GuessIndent
  244. " }}}
  245. " {{{ Smart-splits
  246. " }}}
  247. " End plugins usage desctiptions }}}
  248. "{{{ Plugins installation (Vim-plug)
  249. "-------- Plugins ------------------------------------------------------------------------------------
  250. " site
  251. " https://neovimcraft.com/
  252. call plug#begin()
  253. " {{{ nvim UI
  254. " status/tabline for vim
  255. Plug 'https://github.com/vim-airline/vim-airline'
  256. " color schemes for vim
  257. Plug 'https://github.com/rafi/awesome-vim-colorschemes'
  258. " file manager inside vim
  259. Plug 'https://github.com/preservim/nerdtree'
  260. " adds icons for vim plugins (e.g. NerdTree)
  261. Plug 'https://github.com/ryanoasis/vim-devicons'
  262. " Tagbar - browse the tags of the current file
  263. Plug 'https://github.com/preservim/tagbar'
  264. " highlight colors everywhere in vim (when you giving to variable a color definition - it's highlighting) (if be more correct - it finds "=[color_definition]")
  265. " For example
  266. "let a=red
  267. " "red" is highlighted
  268. Plug 'https://github.com/brenoprata10/nvim-highlight-colors'
  269. " nvim notifications
  270. Plug 'https://github.com/rcarriga/nvim-notify'
  271. " Plugin for highlight next types of comments:
  272. " {{{ Types
  273. " PERF: - perfect
  274. " HACK: - weird code behavior
  275. " WARNING: - don't eat white snow
  276. " TODO: - wake up
  277. " NOTE: - adding a note
  278. " FIX: - need to fix this shit
  279. " BUG: - real bug in code
  280. " }}}
  281. "
  282. " *TODO is highlighted by some plugin higher. May be conflicts
  283. " requires ripgrep package (optional, for search)
  284. Plug 'https://github.com/folke/todo-comments.nvim'
  285. " End nvim UI}}}
  286. " {{{ Unused plugins
  287. " realtime show colors in .css (css, rgb and words)
  288. "Plug 'https://github.com/ap/vim-css-color'
  289. " check it later
  290. "Plug 'https://github.com/mattn/emmet-vim'
  291. " End unused plugins}}}
  292. " {{{ Requirments
  293. " todo-comments requirment (optional, for search)
  294. Plug 'https://github.com/nvim-lua/plenary.nvim'
  295. " Trouble requirment (or U can find theme, what required for Trouble)
  296. Plug 'https://github.com/folke/lsp-colors.nvim'
  297. " todo-comments requirment (optional)
  298. Plug 'https://github.com/folke/trouble.nvim'
  299. " End requirments}}}
  300. " languages helper (autotips)
  301. Plug 'https://github.com/neoclide/coc.nvim', {'branch': 'master', 'do': 'yarn install --frozen-lockfile'}
  302. " code snippets
  303. Plug 'https://github.com/neoclide/coc-snippets'
  304. " all about "surroundings": parentheses, brackets, quotes, XML tags and more
  305. " Delete, change and add surroundings in pairs
  306. Plug 'https://github.com/tpope/vim-surround'
  307. " Multiple cursors in vim
  308. Plug 'https://github.com/terryma/vim-multiple-cursors'
  309. " Adds line (in line numbers col) that shows changes in the file (saved/etc) (like VSCode)
  310. Plug 'https://github.com/lewis6991/gitsigns.nvim'
  311. " Autopair plugin
  312. Plug 'https://github.com/windwp/nvim-autopairs'
  313. " Show popup with key bindings (U should write descriptions manually)
  314. " Plug 'https://github.com/folke/which-key.nvim'
  315. " UI Component lib for nvim
  316. " Plug 'https://github.com/MunifTanjim/nui.nvim'
  317. " Modified autointent
  318. "Plug 'https://github.com/NMAC427/guess-indent.nvim'
  319. " Split pane management
  320. Plug 'https://github.com/mrjones2014/smart-splits.nvim'
  321. " Generate docstrings for python
  322. Plug 'https://github.com/pixelneo/vim-python-docstring'
  323. " Advanced folding
  324. Plug 'https://github.com/anuvyklack/pretty-fold.nvim'
  325. " preview folds
  326. Plug 'https://github.com/anuvyklack/fold-preview.nvim'
  327. " Folding for python
  328. Plug 'https://github.com/tmhedberg/SimpylFold'
  329. call plug#end()
  330. "-------- End plugins ------------------------------------------------------------------------------
  331. "}}}
  332. "{{{ Things after plugins load
  333. "-------- Things after plugins load ----------------------------------------------------------------
  334. " {{{ Activate NERDTree, highligt, todo-comments, git-signs
  335. " Turn on devicons in NERDTree
  336. let g:webdevicons_enable_nerdtree = 1
  337. " turn highlight on (nvim-highlight-colors)
  338. :lua require("nvim-highlight-colors").turnOn()
  339. " activate todo-comments
  340. :lua require("todo-comments").setup()
  341. " activate git-signs
  342. :lua require("gitsigns").setup()
  343. " }}}
  344. " {{{ autopair plugin
  345. lua << AUTOPAIR
  346. require("nvim-autopairs").setup {}
  347. -- Default values {{{
  348. local disable_filetype = { "TelescopePrompt", "spectre_panel" }
  349. local disable_in_macro = true -- disable when recording or executing a macro
  350. local disable_in_visualblock = false -- disable when insert after visual block mode
  351. local disable_in_replace_mode = true
  352. local ignored_next_char = [=[[%w%%%'%[%"%.%`%$]]=]
  353. local enable_moveright = true
  354. local enable_afterquote = true -- add bracket pairs after quote
  355. local enable_check_bracket_line = true --- check bracket in same line
  356. local enable_bracket_in_quote = true --
  357. local enable_abbr = false -- trigger abbreviation
  358. local break_undo = true -- switch for basic rule break undo sequence
  359. local check_ts = false
  360. local map_cr = false
  361. local map_bs = false -- map the <BS> key
  362. local map_c_h = false -- Map the <C-h> key to delete a pair
  363. local map_c_w = false -- map <c-w> to delete a pair if possible
  364. -- End default values }}}
  365. -- {{{ Key mappings
  366. -- local remap = vim.api.nvim_set_keymap
  367. -- local npairs = require('nvim-autopairs')
  368. --
  369. -- npairs.setup({ map_bs = false, map_cr = false })
  370. --
  371. -- vim.g.coq_settings = { keymap = { recommended = false } }
  372. --
  373. -- -- these mappings are coq recommended mappings unrelated to nvim-autopairs
  374. -- remap('i', '<esc>', [[pumvisible() ? "<c-e><esc>" : "<esc>"]], { expr = true, noremap = true })
  375. -- remap('i', '<c-c>', [[pumvisible() ? "<c-e><c-c>" : "<c-c>"]], { expr = true, noremap = true })
  376. -- remap('i', '<tab>', [[pumvisible() ? "<c-n>" : "<tab>"]], { expr = true, noremap = true })
  377. -- remap('i', '<s-tab>', [[pumvisible() ? "<c-p>" : "<bs>"]], { expr = true, noremap = true })
  378. --
  379. -- -- skip it, if you use another global object
  380. -- _G.MUtils= {}
  381. --
  382. -- MUtils.CR = function()
  383. -- if vim.fn.pumvisible() ~= 0 then
  384. -- if vim.fn.complete_info({ 'selected' }).selected ~= -1 then
  385. -- return npairs.esc('<c-y>')
  386. -- else
  387. -- return npairs.esc('<c-e>') .. npairs.autopairs_cr()
  388. -- end
  389. -- else
  390. -- return npairs.autopairs_cr()
  391. -- end
  392. -- end
  393. -- remap('i', '<cr>', 'v:lua.MUtils.CR()', { expr = true, noremap = true })
  394. --
  395. -- MUtils.BS = function()
  396. -- if vim.fn.pumvisible() ~= 0 and vim.fn.complete_info({ 'mode' }).mode == 'eval' then
  397. -- return npairs.esc('<c-e>') .. npairs.autopairs_bs()
  398. -- else
  399. -- return npairs.autopairs_bs()
  400. -- end
  401. -- end
  402. -- remap('i', '<bs>', 'v:lua.MUtils.BS()', { expr = true, noremap = true })
  403. -- End key mappings }}}
  404. AUTOPAIR
  405. " }}}
  406. " setting nvim-notify as default notify function
  407. :lua vim.notify = require("notify")
  408. " {{{ GuessIndent plugin
  409. "lua << GUESSINDENT
  410. "-- This is the default configuration
  411. "require('guess-indent').setup {
  412. " auto_cmd = true, -- Set to false to disable automatic execution
  413. " override_editorconfig = false, -- Set to true to override settings set by .editorconfig
  414. " filetype_exclude = { -- A list of filetypes for which the auto command gets disabled
  415. " "netrw",
  416. " "tutor",
  417. " },
  418. " buftype_exclude = { -- A list of buffer types for which the auto command gets disabled
  419. " "help",
  420. " "nofile",
  421. " "terminal",
  422. " "prompt",
  423. " },
  424. "}
  425. "GUESSINDENT
  426. " End GuessIndent plugin }}}
  427. " {{{ Smart-splits plugin
  428. lua << Smart-Splits
  429. -- Default configuration
  430. require('smart-splits').setup({
  431. -- Ignored filetypes (only while resizing)
  432. ignored_filetypes = {
  433. 'nofile',
  434. 'quickfix',
  435. 'prompt',
  436. },
  437. -- Ignored buffer types (only while resizing)
  438. ignored_buftypes = { 'NvimTree' },
  439. -- the default number of lines/columns to resize by at a time
  440. default_amount = 3,
  441. -- Desired behavior when your cursor is at an edge and you
  442. -- are moving towards that same edge:
  443. -- 'wrap' => Wrap to opposite side
  444. -- 'split' => Create a new split in the desired direction
  445. -- 'stop' => Do nothing
  446. -- function => You handle the behavior yourself
  447. -- NOTE: If using a function, the function will be called with
  448. -- a context object with the following fields:
  449. -- {
  450. -- mux = {
  451. -- type:'tmux'|'wezterm'|'kitty'
  452. -- current_pane_id():number,
  453. -- is_in_session(): boolean
  454. -- current_pane_is_zoomed():boolean,
  455. -- -- following methods return a boolean to indicate success or failure
  456. -- current_pane_at_edge(direction:'left'|'right'|'up'|'down'):boolean
  457. -- next_pane(direction:'left'|'right'|'up'|'down'):boolean
  458. -- resize_pane(direction:'left'|'right'|'up'|'down'):boolean
  459. -- split_pane(direction:'left'|'right'|'up'|'down',size:number|nil):boolean
  460. -- },
  461. -- direction = 'left'|'right'|'up'|'down',
  462. -- split(), -- utility function to split current Neovim pane in the current direction
  463. -- wrap(), -- utility function to wrap to opposite Neovim pane
  464. -- }
  465. -- NOTE: `at_edge = 'wrap'` is not supported on Kitty terminal
  466. -- multiplexer, as there is no way to determine layout via the CLI
  467. at_edge = 'wrap',
  468. -- when moving cursor between splits left or right,
  469. -- place the cursor on the same row of the *screen*
  470. -- regardless of line numbers. False by default.
  471. -- Can be overridden via function parameter, see Usage.
  472. move_cursor_same_row = false,
  473. -- whether the cursor should follow the buffer when swapping
  474. -- buffers by default; it can also be controlled by passing
  475. -- `{ move_cursor = true }` or `{ move_cursor = false }`
  476. -- when calling the Lua function.
  477. cursor_follows_swapped_bufs = false,
  478. -- resize mode options
  479. resize_mode = {
  480. -- key to exit persistent resize mode
  481. quit_key = '<ESC>',
  482. -- keys to use for moving in resize mode
  483. -- in order of left, down, up' right
  484. resize_keys = { 'h', 'j', 'k', 'l' },
  485. -- set to true to silence the notifications
  486. -- when entering/exiting persistent resize mode
  487. silent = false,
  488. -- must be functions, they will be executed when
  489. -- entering or exiting the resize mode
  490. hooks = {
  491. on_enter = nil,
  492. on_leave = nil,
  493. },
  494. },
  495. -- ignore these autocmd events (via :h eventignore) while processing
  496. -- smart-splits.nvim computations, which involve visiting different
  497. -- buffers and windows. These events will be ignored during processing,
  498. -- and un-ignored on completed. This only applies to resize events,
  499. -- not cursor movement events.
  500. ignored_events = {
  501. 'BufEnter',
  502. 'WinEnter',
  503. },
  504. -- enable or disable a multiplexer integration;
  505. -- automatically determined, unless explicitly disabled or set,
  506. -- by checking the $TERM_PROGRAM environment variable,
  507. -- and the $KITTY_LISTEN_ON environment variable for Kitty
  508. multiplexer_integration = nil,
  509. -- disable multiplexer navigation if current multiplexer pane is zoomed
  510. -- this functionality is only supported on tmux and Wezterm due to kitty
  511. -- not having a way to check if a pane is zoomed
  512. disable_multiplexer_nav_when_zoomed = true,
  513. -- Supply a Kitty remote control password if needed,
  514. -- or you can also set vim.g.smart_splits_kitty_password
  515. -- see https://sw.kovidgoyal.net/kitty/conf/#opt-kitty.remote_control_password
  516. kitty_password = nil,
  517. -- default logging level, one of: 'trace'|'debug'|'info'|'warn'|'error'|'fatal'
  518. log_level = 'info',
  519. })
  520. Smart-Splits
  521. " }}}
  522. " {{{ fold-preview plugin
  523. lua << FoldPreview
  524. require('fold-preview').setup({
  525. -- Your configuration goes here.
  526. -- Auto open preview (integer | false)
  527. auto = 400,
  528. -- Default is true
  529. default_keybindings = false,
  530. -- defalut is {' ', '', ' ', ' ', ' ', ' ', ' ', ' '}
  531. -- "none" | "single" | "double" | "rounded" | "solid" | "shadow" | string[]
  532. border = "single",
  533. -- keybinds
  534. -- show preview on closed fold
  535. -- h
  536. -- open fold
  537. -- hh
  538. -- When preview opened, close it and open fold
  539. --
  540. })
  541. FoldPreview
  542. " End fold-preview plugin}}}
  543. " {{{ Pretty Fold plugin
  544. lua << PrettyFold
  545. -- {{{ Global pretty config
  546. local global_pretty_config = function()
  547. require('pretty-fold').setup({
  548. sections = {
  549. left = {
  550. --function() return string.rep('+', vim.v.foldlevel) end,
  551. function() return 'level: '..tonumber(vim.v.foldlevel) end,
  552. ', ',
  553. 'number_of_folded_lines',
  554. ': ',
  555. 'percentage',
  556. ' ',
  557. 'content',
  558. },
  559. right = {
  560. --' ', 'number_of_folded_lines', ': ', 'percentage', ' ',
  561. --function(config) return config.fill_char:rep(3) end
  562. --function(global_pretty_config) return global_pretty_config.fill_char:rep(5) end
  563. },
  564. },
  565. --fill_char = '•',
  566. -- more chars: '┣', '┫'
  567. fill_char = '━',
  568. remove_fold_markers = true,
  569. -- keep the indentation of the content of the fold string.
  570. keep_indentation = true,
  571. -- possible values:
  572. -- "delete" : delete all comment signs from the fold string.
  573. -- "spaces" : replace all comment signs with equal number of spaces.
  574. -- false : do nothing with comment signs.
  575. process_comment_signs = 'spaces',
  576. --process_comment_signs = false,
  577. -- comment signs additional to the value of `&commentstring` option.
  578. --comment_signs = {},
  579. comment_signs = {
  580. '"""', -- python docstring
  581. '#', -- python and bash comments
  582. '--', -- lua comment
  583. '//', -- c languages comment
  584. -- not working (err in init.lua, line 78)
  585. --{ "/*", "*/" },
  586. },
  587. -- list of patterns that will be removed from content foldtext section.
  588. stop_words = {
  589. '@brief%s*', -- (for c++) remove '@brief' and all spaces after.
  590. },
  591. add_close_pattern = true, -- true, 'last_line' or false
  592. matchup_patterns = {
  593. { '{', '}' },
  594. { '%(', ')' }, -- % to escape lua pattern char
  595. { '%[', ']' }, -- % to escape lua pattern char
  596. },
  597. ft_ignore = { 'neorg' },
  598. })
  599. end
  600. -- End global pretty config }}}
  601. -- {{{ Python pretty config
  602. local python_pretty_config = function()
  603. require('pretty-fold').ft_setup('python', {
  604. sections = {
  605. left = {
  606. --function() return string.rep('+', vim.v.foldlevel) end,
  607. function() return 'level: '..tonumber(vim.v.foldlevel) end,
  608. ', ',
  609. 'number_of_folded_lines',
  610. ': ',
  611. 'percentage',
  612. ' ',
  613. 'content',
  614. },
  615. right = {
  616. --' ', 'number_of_folded_lines', ': ', 'percentage', ' ',
  617. --function(config) return config.fill_char:rep(3) end
  618. --function(global_pretty_config) return global_pretty_config.fill_char:rep(5) end
  619. },
  620. },
  621. --fill_char = '•',
  622. -- more chars: '┣', '┫'
  623. fill_char = '━',
  624. remove_fold_markers = true,
  625. -- keep the indentation of the content of the fold string.
  626. keep_indentation = true,
  627. -- possible values:
  628. -- "delete" : delete all comment signs from the fold string.
  629. -- "spaces" : replace all comment signs with equal number of spaces.
  630. -- false : do nothing with comment signs.
  631. process_comment_signs = 'spaces',
  632. --process_comment_signs = false,
  633. -- comment signs additional to the value of `&commentstring` option.
  634. --comment_signs = {},
  635. comment_signs = {
  636. '"""', -- python docstring
  637. '#', -- python and bash comments
  638. '--', -- lua comment
  639. '//', -- c languages comment
  640. -- not working (err in init.lua, line 78)
  641. --{ "/*", "*/" },
  642. },
  643. -- list of patterns that will be removed from content foldtext section.
  644. stop_words = {
  645. '@brief%s*', -- (for c++) remove '@brief' and all spaces after.
  646. },
  647. add_close_pattern = true, -- true, 'last_line' or false
  648. matchup_patterns = {
  649. { '^%s*if%s*:', '^%s %s'},
  650. { '{', '}' },
  651. { '%(', ')' }, -- % to escape lua pattern char
  652. { '%[', ']' }, -- % to escape lua pattern char
  653. },
  654. })
  655. end
  656. -- End python pretty config }}}
  657. -- {{{ Lua pretty config
  658. local lua_pretty_config = function()
  659. require('pretty-fold').ft_setup('python', {
  660. matchup_patterns = {
  661. { '^%s*do$', 'end' }, -- do ... end blocks
  662. { '^%s*if', 'end' }, -- if ... end
  663. { '^%s*for', 'end' }, -- for
  664. { 'function%s*%(', 'end' }, -- 'function( or 'function (''
  665. { '{', '}' },
  666. { '%(', ')' }, -- % to escape lua pattern char
  667. { '%[', ']' }, -- % to escape lua pattern char
  668. },
  669. })
  670. end
  671. -- End lua pretty config }}}
  672. global_pretty_config()
  673. python_pretty_config()
  674. lua_pretty_config()
  675. PrettyFold
  676. " End pretty fold plugin }}}
  677. " {{{SimpylFold
  678. let g:SimpylFold_docstring_preview = 1
  679. let g:SimpylFold_fold_docstring = 1
  680. let g:SimpylFold_fold_import = 1
  681. let g:SimpylFold_fold_blank = 0
  682. " EndSimplyFold}}}
  683. " ---------- End things after plugins load -----------------------------------------------------------
  684. " }}} Things after plugins load
  685. " {{{ Hotkeys
  686. "-------- Hotkeys ---------------------------------------------------------------------------------
  687. " FOR CHECK hotkey use command
  688. ":verbose imap [key]
  689. " e.g.
  690. ":verbose imap <Tab>
  691. " {{{ NERDTree
  692. " Ctrl+N for open NerdTree
  693. "nnoremap <C-n> :NERDTree<CR>
  694. " Ctrl+T for open/close NerdTree
  695. nnoremap <C-t> :NERDTreeToggle<CR>
  696. " F8 for open Tagbar
  697. nmap <F8> :TagbarToggle<CR>
  698. " }}}
  699. " {{{ Coc (autocomplete)
  700. "------ Coc (autocomplete)
  701. " Alt+Tab for next variant of completion and Shift+Tab for previous
  702. inoremap <silent><expr> <a-TAB>
  703. \ coc#pum#visible() ? coc#pum#next(1) :
  704. \ CheckBackspace() ? "\<Tab>" :
  705. \ coc#refresh()
  706. inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
  707. "inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
  708. " \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
  709. " use Shift+Enter for accept completion
  710. inoremap <silent><expr> <S-CR> coc#pum#confirm()
  711. " use Ctrl+Space to trigger completion
  712. inoremap <silent><expr> <c-space> coc#refresh()
  713. " go to definition
  714. nmap <silent> gd <Plug>(coc-definition)
  715. nmap <silent> gy <Plug>(coc-type-definition)
  716. nmap <silent> gi <Plug>(coc-implementation)
  717. " go to references
  718. nmap <silent> gr <Plug>(coc-references)
  719. "------ end Coc (autocomplete)
  720. "}}}
  721. " {{{ coc-snippets
  722. "inoremap <silent><expr> <a-TAB>
  723. " \ coc#pum#visible() ? coc#_select_confirm() :
  724. " \ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :
  725. " \ CheckBackspace() ? "\<TAB>" :
  726. " \ coc#refresh()
  727. "
  728. "function! CheckBackspace() abort
  729. " let col = col('.') - 1
  730. " return !col || getline('.')[col - 1] =~# '\s'
  731. "endfunction
  732. "
  733. "let g:coc_snippet_next = '<tab>'
  734. " }}}
  735. " turn off search highlight
  736. " , and Space
  737. nnoremap ,<space> :nohlsearch<CR>
  738. " for insert mode - escape by jk
  739. "inoremap jk <esc>
  740. "
  741. " {{{ VIM go to smth
  742. " go to next vim buffer
  743. nnoremap gn :bnext<CR>
  744. " go to prev vim buffer
  745. nnoremap gp :bprevious<CR>
  746. " close buffer
  747. nnoremap gw :bdelete<CR>
  748. " buffer list
  749. nnoremap gl :buffers<CR>
  750. " }}}
  751. " {{{ VIM split
  752. nnoremap <S-l> :vsplit
  753. nnoremap <S-j> :split
  754. " End VIM split}}}
  755. " {{{ smart-splits
  756. lua << smart-splits-keys
  757. -- recommended mappings
  758. -- resizing splits
  759. -- these keymaps will also accept a range,
  760. -- for example `10<A-h>` will `resize_left` by `(10 * config.default_amount)`
  761. vim.keymap.set('n', '<A-h>', require('smart-splits').resize_left)
  762. vim.keymap.set('n', '<A-j>', require('smart-splits').resize_down)
  763. vim.keymap.set('n', '<A-k>', require('smart-splits').resize_up)
  764. vim.keymap.set('n', '<A-l>', require('smart-splits').resize_right)
  765. -- moving between splits
  766. vim.keymap.set('n', '<C-h>', require('smart-splits').move_cursor_left)
  767. vim.keymap.set('n', '<C-j>', require('smart-splits').move_cursor_down)
  768. vim.keymap.set('n', '<C-k>', require('smart-splits').move_cursor_up)
  769. vim.keymap.set('n', '<C-l>', require('smart-splits').move_cursor_right)
  770. -- swapping buffers between windows
  771. vim.keymap.set('n', '<leader><leader>h', require('smart-splits').swap_buf_left)
  772. vim.keymap.set('n', '<leader><leader>j', require('smart-splits').swap_buf_down)
  773. vim.keymap.set('n', '<leader><leader>k', require('smart-splits').swap_buf_up)
  774. vim.keymap.set('n', '<leader><leader>l', require('smart-splits').swap_buf_right)
  775. -- adding smart-split
  776. --vim.keymap.set('n', '<S-l>', require('smart-splits').split_pane_right)
  777. --vim.keymap.set('n', '<S-k>', require('smart-splits').resize_up)
  778. smart-splits-keys
  779. " }}}
  780. "-------- End hotkeys --------------------------------------------------------------------------------
  781. "}}}
  782. " {{{ Functions
  783. "-------- Functions ----------------------------------------------------------------------------------
  784. " {{{ for coc autocomplete
  785. " For coc autocomplete
  786. function! CheckBackspace() abort
  787. let col = col('.') - 1
  788. return !col || getline('.')[col - 1] =~# '\s'
  789. endfunction
  790. " }}}
  791. "-------- End functions ------------------------------------------------------------------------------
  792. " }}}