init.lua 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. vim.o.completeopt = "menuone,noselect"
  2. require'compe'.setup {
  3. enabled = true,
  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. treesitter = {kind = "  "},
  26. emoji = {kind = " ﲃ "}
  27. -- for emoji press : (idk if that in compe tho)
  28. }
  29. }
  30. -- 
  31. -- 
  32. -- 
  33. -- 
  34. -- 
  35. -- 
  36. -- 
  37. -- 
  38. -- 
  39. -- 
  40. -- 
  41. -- 
  42. -- 
  43. -- 
  44. -- 
  45. -- 
  46. -- ﬘
  47. -- 
  48. -- 
  49. -- 
  50. -- m
  51. -- 
  52. -- 
  53. -- 
  54. -- 
  55. local t = function(str)
  56. return vim.api.nvim_replace_termcodes(str, true, true, true)
  57. end
  58. local check_back_space = function()
  59. local col = vim.fn.col('.') - 1
  60. if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then
  61. return true
  62. else
  63. return false
  64. end
  65. end
  66. -- Use (s-)tab to:
  67. --- move to prev/next item in completion menuone
  68. --- jump to prev/next snippet's placeholder
  69. _G.tab_complete = function()
  70. if vim.fn.pumvisible() == 1 then
  71. return t "<C-n>"
  72. elseif vim.fn.call("vsnip#available", {1}) == 1 then
  73. return t "<Plug>(vsnip-expand-or-jump)"
  74. elseif check_back_space() then
  75. return t "<Tab>"
  76. else
  77. return vim.fn['compe#complete']()
  78. end
  79. end
  80. _G.s_tab_complete = function()
  81. if vim.fn.pumvisible() == 1 then
  82. return t "<C-p>"
  83. elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then
  84. return t "<Plug>(vsnip-jump-prev)"
  85. else
  86. return t "<S-Tab>"
  87. end
  88. end
  89. vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", {expr = true})
  90. vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", {expr = true})
  91. vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
  92. vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})