+/config
my dotfiles and nix configuration
git clone https://git.julia.blue/+/config
d0b27c7
main
1local cmp =require "cmp" 2local snippy =require "snippy" 3snippy . setup { hl_group ="SnippetPlaceholder" } 4-- stylua: ignore start 5vim . keymap . set ( { "i" , "n" , "v" } , "<C-l>" , function () 6if snippy . can_jump ( 1 ) then snippy . next () else "No more snippets" end 7end ) 8vim . keymap . set ( { "i" , "n" , "v" } , "<C-h>" , function () 9if snippy . can_jump ( - 1 ) then snippy . previous () else "No more snippets" end 10end ) 11-- stylua: ignore end 12 13require ( "nvim-autopairs" ). setup {} 14local cmp_autopairs =require "nvim-autopairs.completion.cmp" 15cmp . event : on ( "confirm_done" , cmp_autopairs . on_confirm_done ()) 16 17cmp . setup { 18enabled =function () 19return vim . api . nvim_buf_get_option ( 0 , "buftype" ) ~= "prompt" 20or require ( "cmp_dap" ). is_dap_buffer () 21end , 22snippet ={ expand =function ( args ) snippy . expand_snippet ( args . body ) end } , 23performance ={ max_view_entries =20 } , 24sources =cmp . config . sources { 25{ name ="nvim_lsp_signature_help" } , 26{ name ="nvim_lsp" } , 27{ name ="snippy" } , 28{ name ="buffer" } , 29{ name ="path" } , 30} , 31preselect =cmp . PreselectMode . None , 32formatting ={ 33fields ={ "kind" , "abbr" , "menu" } , 34format =function ( entry , item ) 35if vim . tbl_contains ( { "path" } , entry . source . name ) then 36local icon , hl_group = 37require ( "nvim-web-devicons" ). get_icon ( entry : get_completion_item (). label ) 38if icon then 39item . kind =icon 40item . kind_hl_group =hl_group 41return item 42end 43end 44item =require ( "lspkind" ). cmp_format { 45mode ="symbol_text" , 46maxwidth =30 , 47ellipsis_char ="…" , 48} ( entry , item ) 49local strings =vim . split ( item . kind , "%s" , { trimempty =true } ) 50item . kind =" " .. ( strings [ 1 ] or "" ) .. " " 51item . menu =" (" .. ( strings [ 2 ] or "" ) .. ")" 52return item 53end , 54} , 55mapping =cmp . mapping . preset . insert { 56[ "<C-u>" ] =cmp . mapping . scroll_docs ( - 8 ), 57[ "<C-d>" ] =cmp . mapping . scroll_docs ( 8 ), 58[ "<C-e>" ] =cmp . mapping . abort (), 59[ "<Esc>" ] =cmp . mapping ( function ( fallback ) 60cmp . mapping . abort () 61fallback () 62end ), 63[ "<C-Space>" ] =cmp . mapping . complete (), 64[ "<CR>" ] =cmp . mapping ( function ( fallback ) 65if cmp . visible () and cmp . get_active_entry () then 66cmp . confirm { select =false } 67else 68fallback () 69end 70end , { "i" } ), 71[ "<Tab>" ] =cmp . mapping ( function ( fallback ) 72local line , col =table . unpack ( vim . api . nvim_win_get_cursor ( 0 )) 73if cmp . visible () then 74cmp . select_next_item { behavior =cmp . SelectBehavior . Select } 75elseif 76col ~= 0 77and vim . api 78. nvim_buf_get_lines ( 0 , line - 1 , line , true )[ 1 ] 79: sub ( col , col ) 80: match "%s" 81== nil 82then 83cmp . complete () 84else 85fallback () 86end 87end , { "i" } ), 88[ "<S-Tab>" ] =cmp . mapping ( function ( fallback ) 89if cmp . visible () then 90cmp . select_prev_item { behavior =cmp . SelectBehavior . Select } 91else 92fallback () 93end 94end , { "i" } ), 95} , 96} 97 98cmp . setup . filetype ( { "dap-repl" , "dapui_watches" , "dapui_hover" } , { 99sources ={ { name ="dap" } } , 100} )