summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Vink <>2023-04-13 19:14:07 +0200
committerMike Vink <>2023-04-13 19:14:07 +0200
commit5bf899a658326ce0cc09c6373443ac4caf002c60 (patch)
treecba74415831e370f39dc454bca2d4c1a4ae7755d
parentcb9d4e0fb632b5a94077c9cf0d07e6796b2fa407 (diff)
fixup
-rw-r--r--fnl/conf/pkgs/cmp.fnl61
1 files changed, 21 insertions, 40 deletions
diff --git a/fnl/conf/pkgs/cmp.fnl b/fnl/conf/pkgs/cmp.fnl
index 6518f34..12cbec3 100644
--- a/fnl/conf/pkgs/cmp.fnl
+++ b/fnl/conf/pkgs/cmp.fnl
@@ -1,26 +1,22 @@
(local cmp (require :cmp))
(local compare (require :cmp.config.compare))
-(var once false)
+(fn string-startswith? [str start]
+ (= start (string.sub str 1 (string.len start))))
-(local string-startswith
- (fn [str start]
- (= start (string.sub str 1 (string.len start)))))
+(fn string-startswith-anyof? [str start-list]
+ (fn iter [[item & rest]]
+ (if (not item) false
+ (string-startswith? str item) true
+ (iter rest)))
-(local string-startswith-anyof (fn [str start-list]
- (var ret false)
- (each [_ start (ipairs start-list)]
- (do
- (P ret)
- (set ret (string-startswith str start))))
- ret))
+ (iter start-list))
-(local string-startswith-upper
- (fn [str]
- (local first-char (string.sub str 1 1))
- (= first-char (string.upper first-char))))
+(fn string-startswith-upper? [str]
+ (local first-char (string.sub str 1 1))
+ (= first-char (string.upper first-char)))
-(fn has-words-before []
+(fn has-words-before? []
(local [line col] (vim.api.nvim_win_get_cursor 0))
(local [word & rest] (vim.api.nvim_buf_get_lines 0 (- line 1) line true))
(local before (word:sub col col))
@@ -43,7 +39,7 @@
(cmp.select_next_item)
(luasnip.expand_or_jumpable)
(luasnip.expand_or_jump)
- (has-words-before)
+ (has-words-before?)
(cmp.complete)
(fallback))
[:i :s]))
@@ -70,35 +66,17 @@
:experimental {:ghost_text true}
:mapping (cmp.mapping.preset.cmdline)})
(cmp.setup.cmdline ":"
- {:matching {:disallow_prefix_unmatching true}
+ {:matching {:disallow_partial_matching true
+ :disallow_prefix_unmatching true}
:sources (cmp.config.sources [{:name :path}]
[{:name :cmdline
:keyword_length 1
:entry_filter (fn [entry
ctx]
- (if (string-startswith-anyof entry.completion_item.label
- [:w
- :sp])
- (do
- (P entry.completion_item.label)
- false)
- true))}])
- :experimental {:ghost_text true}
+ (not (string-startswith-anyof? entry.completion_item.label
+ [:w
+ :sp])))}])
:preselect cmp.PreselectMode.Item
- ; :completion {:keyword_length 2}
- :sorting {:priority_weight 2
- :comparators [compare.order
- compare.exact
- compare.length]}
- ; compare.offset
- ; compare.scopes
- ; compare.length
- ; compare.recently_used
- ; compare.exact]}
- ;compare.score]}
- ; compare.locality]}
- ; compare.kind]}
- ; compare.sort_text
:mapping (cmp.mapping.preset.cmdline {:<CR> {:c (fn [fallback]
(if (not (cmp.confirm {:behavior (enum :ConfirmBehavior
:Replace)
@@ -114,4 +92,7 @@
; true
; false))
; :max_item_count 1)})))
+; disallow_fuzzy_matching = false,
+; disallow_partial_matching = false,
+; disallow_prefix_unmatching = false,)))
(cmp-setup cmp true)