init.lua 2.4 KB

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