init.lua 2.3 KB

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