robin/ivy
my custom neovim config
git clone https://git.robinwobin.dev/robin/ivy
4fb7125
main
1-- https://github.com/echasnovski/nvim/blob/0a87022921d2e2a95fb987c4f11fc4804b57d6f9/plugin/21_functions.lua#L23 2 3vim . keymap . set ( "n" , "<Plug>(ivy-insert-section)" , function () 4local lnum =vim . fn . line ( "." ) 5local symbol ="=" 6local total_width =vim . o . textwidth > 0 and vim . o . textwidth or 79 7 8local indent =vim . fn . indent ( lnum ) 9if indent == - 1 then 10return 11end 12-- on empty lines: inherit indent of previous non-empty line 13local lnum_ =lnum 14while 15indent == 0 16and # vim . api . nvim_buf_get_lines ( 0 , lnum_ - 1 , lnum_ , true )[ 1 ] == 0 17and lnum_ > 0 18do 19lnum_ =lnum_ - 1 20indent =vim . fn . indent ( lnum_ ) 21end 22local indent_str =string . rep ( " " , indent ) 23 24-- use 'commentstring' with '%s' replaced by section symbols and prepended 25-- with indent_str 26local comment_string =vim . bo . commentstring 27local comment_str_len =# comment_string : format ( "" ) 28local content =string . rep ( symbol , total_width - indent - comment_str_len ) 29local section_template =indent_str .. comment_string : format ( content ) 30vim . api . nvim_buf_set_lines ( 0 , lnum - 1 , lnum , true , { section_template } ) 31 32-- start replace mode at inner start 33local inner_start =comment_string : find ( "%%s" ) + indent 34vim . fn . cursor ( lnum , inner_start ) 35vim . cmd . startreplace () 36end ) 37 38vim . keymap . set ( "n" , "<leader>is" , "<Plug>(ivy-insert-section)" )