compe-config.lua 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. -- TODO we need snippet support and to maybe get better docs idk
  2. vim.o.completeopt = "menuone,noselect"
  3. require'compe'.setup {
  4. enabled = true;
  5. autocomplete = true;
  6. debug = false;
  7. min_length = 1;
  8. preselect = 'enable';
  9. throttle_time = 80;
  10. source_timeout = 200;
  11. incomplete_delay = 400;
  12. max_abbr_width = 100;
  13. max_kind_width = 100;
  14. max_menu_width = 100;
  15. documentation = false;
  16. source = {
  17. path = true;
  18. buffer = true;
  19. calc = true;
  20. vsnip = true;
  21. nvim_lsp = true;
  22. nvim_lua = true;
  23. spell = true;
  24. tags = true;
  25. snippets_nvim = true;
  26. treesitter = true;
  27. };
  28. }
  29. local t = function(str)
  30. return vim.api.nvim_replace_termcodes(str, true, true, true)
  31. end
  32. -- local check_back_space = function()
  33. -- local col = vim.fn.col('.') - 1
  34. -- if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then
  35. -- return true
  36. -- else
  37. -- return false
  38. -- end
  39. -- end
  40. -- Use (s-)tab to:
  41. --- move to prev/next item in completion menuone
  42. --- jump to prev/next snippet's placeholder
  43. -- _G.tab_complete = function()
  44. -- if vim.fn.pumvisible() == 1 then
  45. -- return t "<C-n>"
  46. -- elseif vim.fn.call("vsnip#available", {1}) == 1 then
  47. -- return t "<Plug>(vsnip-expand-or-jump)"
  48. -- elseif check_back_space() then
  49. -- return t "<Tab>"
  50. -- else
  51. -- return vim.fn['compe#complete']()
  52. -- end
  53. -- end
  54. _G.s_tab_complete = function()
  55. if vim.fn.pumvisible() == 1 then
  56. return t "<C-p>"
  57. elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then
  58. return t "<Plug>(vsnip-jump-prev)"
  59. else
  60. return t "<S-Tab>"
  61. end
  62. end
  63. -- vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", {expr = true})
  64. vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", {expr = true})
  65. vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
  66. vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})