From 770a0226a6eb363337a72354da9ce14fcda52203 Mon Sep 17 00:00:00 2001 From: Mike Vink Date: Sun, 8 Oct 2023 23:22:22 +0200 Subject: fixup --- mut/neovim/fnl/conf/init.fnl | 20 ++++++-------------- mut/neovim/fnl/conf/pkgs.fnl | 15 +++++---------- mut/neovim/fnl/conf/pkgs/cmp.fnl | 40 +++++++++++++++++++++++++++++++++++++--- 3 files changed, 48 insertions(+), 27 deletions(-) (limited to 'mut') 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 {: (cmp.mapping + :mapping {: (cmp.mapping + (fn [fallback] + (if (cmp.visible) + (cmp.select_next_item) + (fallback))) + [:i :c]) + : (cmp.mapping + (fn [fallback] + (if (cmp.visible) + (cmp.select_prev_item) + (fallback))) + [:i :c]) + : (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 "" true false true) false) + (vim.schedule cmp.complete)))) + [:i :c]) + : (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 :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) -- cgit v1.2.3