summaryrefslogtreecommitdiff
path: root/mut
diff options
context:
space:
mode:
authorMike Vink <mike1994vink@gmail.com>2023-10-08 23:22:22 +0200
committerMike Vink <mike1994vink@gmail.com>2023-10-08 23:22:22 +0200
commit770a0226a6eb363337a72354da9ce14fcda52203 (patch)
tree8734fd9f8fe9385510cbec9091545a2a78c8fa20 /mut
parent77ad911a2c758f03c3a3e34b998cedf126f1ce9c (diff)
fixup
Diffstat (limited to 'mut')
-rw-r--r--mut/neovim/fnl/conf/init.fnl20
-rw-r--r--mut/neovim/fnl/conf/pkgs.fnl15
-rw-r--r--mut/neovim/fnl/conf/pkgs/cmp.fnl40
3 files changed, 48 insertions, 27 deletions
diff --git a/mut/neovim/fnl/conf/init.fnl b/mut/neovim/fnl/conf/init.fnl
index a475013..1ee3b7f 100644
--- a/mut/neovim/fnl/conf/init.fnl
+++ b/mut/neovim/fnl/conf/init.fnl
@@ -7,13 +7,11 @@
(require :conf.settings)
(require :conf.pkgs)
-;; (require :conf.lsp)
-;; (require :conf.events)
-;; (require :conf.filetype)
-;; (require :conf.newtab)
-(require :conf.nix-develop)
-
-;; (require :conf.diagnostic)
+(tset _G :P (lambda [...]
+ (let [inspected (icollect [_ v (ipairs [...])]
+ (vim.inspect v))]
+ (each [_ printer (ipairs inspected)]
+ (print printer)))))
(local tel (require :telescope))
(local themes (require :telescope.themes))
@@ -83,6 +81,7 @@
:on_exit (fn [id rc]
(if (= rc 0)
(vim.cmd ":cope")))})))
+
(var last_job nil)
(vim.api.nvim_create_user_command :Compile (fn [cmd]
(set last_job cmd.fargs)
@@ -93,10 +92,3 @@
(job last_job)
(vim.notify "nothing to recompile")))
{:bang true})
-
-
-(tset _G :P (lambda [...]
- (let [inspected (icollect [_ v (ipairs [...])]
- (vim.inspect v))]
- (each [_ printer (ipairs inspected)]
- (print printer)))))
diff --git a/mut/neovim/fnl/conf/pkgs.fnl b/mut/neovim/fnl/conf/pkgs.fnl
index 283edb8..f47ee8e 100644
--- a/mut/neovim/fnl/conf/pkgs.fnl
+++ b/mut/neovim/fnl/conf/pkgs.fnl
@@ -1,14 +1,9 @@
(require :conf.pkgs.cmp)
-
-;; (require :conf.pkgs.null-ls)
-;; (require :conf.pkgs.lspconfig)
+(require :conf.pkgs.lspconfig)
(require :conf.pkgs.treesitter)
(require :conf.pkgs.tree-sitter-context)
-;; (require :conf.pkgs.conjure)
-;; (require :conf.pkgs.test)
+(require :conf.pkgs.dap)
+(require :conf.pkgs.venn)
+(require :conf.pkgs.gitsigns)
;; (require :conf.pkgs.lsp_lines)
-;; (require :conf.pkgs.dap)
-;; (require :conf.pkgs.heirline)
-;; (require :conf.pkgs.gitsigns)
-;; (require :conf.pkgs.harpoon)
-;; (require :conf.pkgs.venn)
+;; (require :conf.pkgs.null-ls)
diff --git a/mut/neovim/fnl/conf/pkgs/cmp.fnl b/mut/neovim/fnl/conf/pkgs/cmp.fnl
index 1edce94..0a22f23 100644
--- a/mut/neovim/fnl/conf/pkgs/cmp.fnl
+++ b/mut/neovim/fnl/conf/pkgs/cmp.fnl
@@ -10,6 +10,15 @@
(fn edit? [line]
(not= nil (line:match "^ed?i?t? .*$")))
+(fn endswith? [line char]
+ (not= nil (line:match (.. ".*" char "$"))))
+
+(fn replace-tail [line]
+ (let [(result n) (line:gsub "(.*/)[^/]*/$" "%1")]
+ (if (not= nil n)
+ result
+ line)))
+
(fn enum [types key]
(. (. cmp types) key))
@@ -56,7 +65,29 @@
(cmp.close))
val)
:completion {:completeopt "menu,menuone,noinsert"}
- :mapping {:<CR> (cmp.mapping
+ :mapping {:<C-n> (cmp.mapping
+ (fn [fallback]
+ (if (cmp.visible)
+ (cmp.select_next_item)
+ (fallback)))
+ [:i :c])
+ :<C-p> (cmp.mapping
+ (fn [fallback]
+ (if (cmp.visible)
+ (cmp.select_prev_item)
+ (fallback)))
+ [:i :c])
+ :<BS> (cmp.mapping
+ (fn [fallback]
+ (local line (vim.fn.getcmdline))
+ (if (not (endswith? line "/"))
+ (fallback)
+ (do
+ (vim.fn.setcmdline (replace-tail line))
+ (vim.fn.feedkeys (vim.api.nvim_replace_termcodes "<C-g><BS>" true false true) false)
+ (vim.schedule cmp.complete))))
+ [:i :c])
+ :<CR> (cmp.mapping
(fn [fallback]
(local entry (cmp.get_selected_entry))
(local line (vim.fn.getcmdline))
@@ -72,7 +103,7 @@
(vim.schedule fallback))))))
[:i :c])}
:sources (cmp.config.sources
- [{:name :cmdline} {:name :path}])}
+ [{:name :cmdline :trigger_characters []} {:name :path}])}
@@ -82,7 +113,10 @@
(let [map vim.keymap.set]
(map :n :<leader>xf (fn []
- (vim.api.nvim_feedkeys (.. ":e " (vim.fn.getcwd)) :c false)
+ (local fname (vim.fn.fnamemodify
+ (vim.fn.bufname (vim.api.nvim_get_current_buf))
+ ::p:h))
+ (vim.api.nvim_feedkeys (.. ":e " fname) :c false)
(vim.defer_fn #(vim.api.nvim_feedkeys "/" :c false) 10))))
(cmp-setup (require :cmp) true)