init.lua 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. vim.o.completeopt = "menuone,noselect"
  2. require'compe'.setup {
  3. enabled = AUTO_COMPLETE,
  4. autocomplete = true,
  5. debug = false,
  6. min_length = 1,
  7. preselect = 'enable',
  8. throttle_time = 80,
  9. source_timeout = 200,
  10. incomplete_delay = 400,
  11. max_abbr_width = 100,
  12. max_kind_width = 100,
  13. max_menu_width = 100,
  14. documentation = true,
  15. source = {
  16. path = {kind = "  "},
  17. buffer = {kind = "  "},
  18. calc = {kind = "  "},
  19. vsnip = {kind = "  "},
  20. nvim_lsp = {kind = "  "},
  21. nvim_lua = {kind = "  "},
  22. spell = {kind = "  "},
  23. tags = false,
  24. -- snippets_nvim = {kind = "  "},
  25. -- ultisnips = {kind = "  "},
  26. treesitter = {kind = "  "},
  27. emoji = {kind = " ﲃ ", filetypes={"markdown"}}
  28. -- for emoji press : (idk if that in compe tho)
  29. }
  30. }
  31. -- 
  32. -- 
  33. -- 
  34. -- 
  35. -- 
  36. -- 
  37. -- 
  38. -- 
  39. -- 
  40. -- 
  41. -- 
  42. -- 
  43. -- 
  44. -- 
  45. -- 
  46. -- 
  47. -- ﬘
  48. -- 
  49. -- 
  50. -- 
  51. -- m
  52. -- 
  53. -- 
  54. -- 
  55. -- 
  56. local t = function(str)
  57. return vim.api.nvim_replace_termcodes(str, true, true, true)
  58. end
  59. local check_back_space = function()
  60. local col = vim.fn.col('.') - 1
  61. if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then
  62. return true
  63. else
  64. return false
  65. end
  66. end
  67. -- Use (s-)tab to:
  68. --- move to prev/next item in completion menuone
  69. --- jump to prev/next snippet's placeholder
  70. _G.tab_complete = function()
  71. if vim.fn.pumvisible() == 1 then
  72. return t "<C-n>"
  73. elseif vim.fn.call("vsnip#available", {1}) == 1 then
  74. return t "<Plug>(vsnip-expand-or-jump)"
  75. elseif check_back_space() then
  76. return t "<Tab>"
  77. else
  78. return vim.fn['compe#complete']()
  79. end
  80. end
  81. _G.s_tab_complete = function()
  82. if vim.fn.pumvisible() == 1 then
  83. return t "<C-p>"
  84. elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then
  85. return t "<Plug>(vsnip-jump-prev)"
  86. else
  87. return t "<S-Tab>"
  88. end
  89. end
  90. vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", {expr = true})
  91. vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", {expr = true})
  92. vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
  93. vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})