completree-config.lua (2256B)
1 local comp = require "complementree" 2 local s = require "complementree.sources" 3 local cdef = require 'complementree.defaults' 4 local cc = require "complementree.combinators" 5 local ccomp = require 'complementree.comparators' 6 local cf = require 'complementree.filters' 7 local utils = require 'complementree.utils' 8 local api = vim.api 9 10 11 local function zest_complete(ltc, _) 12 local preffix = utils.prefix.lua_regex("[a-zA-Z0-9_-./\\]+", ltc) 13 local query 14 if preffix and #preffix ~= 0 then 15 query = string.format("*%s*", preffix) 16 else 17 query = "*" 18 end 19 local files = vim.fn.systemlist { "zest", "search", query } 20 21 22 local ret = {} 23 for _, fname in ipairs(files) do 24 local fullpath, title = unpack(vim.split(fname, ':', true)) 25 table.insert(ret, { 26 word = vim.fn.fnamemodify(fullpath, ":p:t"), 27 menu = title, 28 kind = "F" 29 }) 30 end 31 32 return ret, preffix 33 end 34 35 local function md_complete(...) 36 local fullpath = vim.fn.expand "%:p" 37 if vim.fn.executable 'zest' == 1 and #(vim.fn.system { 'zest', 'search', string.format('file:%s', fullpath) }) ~= 0 then 38 cc.wrap(zest_complete)(...) 39 else 40 cdef.ins_completion("C-F")(...) 41 end 42 end 43 44 local fuzzy_lsp = cc.pipeline(s.lsp_matches {}, ccomp.fzy) 45 46 local lsp_completion = { 47 default = fuzzy_lsp, 48 string = cdef.ins_completion "C-F", 49 comment = cdef.dummy, 50 -- comment = cdef.snippy, 51 } 52 53 comp.setup { 54 default = cdef.ins_completion "C-N", 55 vim = cdef.ins_completion "C-V", 56 dockerfile = cdef.ins_completion "C-F", 57 query = cdef.ins_completion 'C-O', 58 org = cdef.ins_completion 'C-O', 59 c = lsp_completion, 60 cpp = lsp_completion, 61 lua = { 62 default = fuzzy_lsp, 63 string = cdef.ins_completion "C-F", 64 }, 65 rust = lsp_completion, 66 ocaml = lsp_completion, 67 python = lsp_completion, 68 ql = lsp_completion, 69 cmake = lsp_completion, 70 nix = { default = fuzzy_lsp, path_expression = cdef.ins_completion "C-F", path_fragment = cdef.ins_completion "C-F" }, 71 tex = lsp_completion, 72 haskell = lsp_completion, 73 go = lsp_completion, 74 javascript = lsp_completion, 75 typescript = lsp_completion, 76 zig = lsp_completion, 77 xml = lsp_completion, 78 html = lsp_completion, 79 80 lean = lsp_completion, 81 82 -- For git commit and text only do luasnip 83 markdown = md_complete 84 }