summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Vink <mike1994vink@gmail.com>2023-10-08 15:53:30 +0200
committerMike Vink <mike1994vink@gmail.com>2023-10-08 15:53:30 +0200
commitd4537746a29fc296eac8c1e707c73b2087dc2bf8 (patch)
tree40d5595ba5c993bcad0e97d67d410b3f88cfc4c8
parent2de0ec60326a9b46ba665228dc789c5ffbc39da8 (diff)
dummy version
-rw-r--r--mut/neovim/fnl/conf/init.fnl62
-rw-r--r--mut/neovim/fnl/conf/pkgs/cmp.fnl90
-rw-r--r--mut/neovim/fnl/conf/pkgs/harpoon.fnl39
-rw-r--r--mut/neovim/fnl/conf/pkgs/test.fnl9
-rw-r--r--mut/neovim/fnl/conf/settings.fnl4
5 files changed, 78 insertions, 126 deletions
diff --git a/mut/neovim/fnl/conf/init.fnl b/mut/neovim/fnl/conf/init.fnl
index 3d3c695..3dec989 100644
--- a/mut/neovim/fnl/conf/init.fnl
+++ b/mut/neovim/fnl/conf/init.fnl
@@ -11,18 +11,22 @@
;; (require :conf.events)
;; (require :conf.filetype)
;; (require :conf.newtab)
-;; (require :conf.nix-develop)
+(require :conf.nix-develop)
;; (require :conf.diagnostic)
+(local tel (require :telescope))
+(local themes (require :telescope.themes))
+(local builtin (require :telescope.builtin))
+(tel.setup
+ {:defaults (vim.tbl_extend :force (themes.get_ivy) {})})
+
(let [map vim.keymap.set]
- (map :t :<c-s> "<c-\\><c-n>")
- ;; pausing and continueing printing output is not necessary inside neovim terminal right?
- (map :t :<c-q> "<c-\\><c-n>:q<cr>")
- (map :n :<leader>qo ":copen<cr>")
- (map :n :<leader>qc ":cclose<cr>")
- (map :n :<leader>lo ":lopen<cr>")
- (map :n :<leader>lc ":lclose<cr>")
+ (map :n :<leader>qf ":copen<cr>")
+ (map :n :<leader>q<BS> ":cclose<cr>")
+ (map :n :<leader>ll ":lopen<cr>")
+ (map :n :<leader>l<BS> ":lclose<cr>")
+ (map :n :<C-space> ":cnext<cr>")
(map :n "[q" ":cprevious<cr>")
(map :n "]q" ":cnext<cr>")
(map :n "[x" ":lprevious<cr>")
@@ -31,9 +35,45 @@
(map :n "`<Backspace>" ":FocusDispatch ")
(map :n "`k" ":K9s ")
(map :n "`s" ":Ssh ")
- (map :n :<leader>p ":NewTab<cr>")
- (map :n :<leader>cf ":tabedit ~/flake|tc ~/flake|G<cr><c-w>o")
- (map :n :<leader>cn ":tabedit ~/neovim|tc ~/neovim|G<cr><c-w>o"))
+ (map :n "<leader>;" ":silent grep ")
+ (map :n :<leader>xb #(builtin.buffers { :sort_mru true :ignore_current_buffer true})))
+
+(set vim.opt.quickfixtextfunc :v:lua.PrettifyQf)
+
+;; I like to use the qf to run a lot of stuff that prints junk
+;; Here I just check if ansi control stuff is printed and reparse the lines with efm
+(tset _G :PrettifyQf
+ (fn [info]
+ (local {: id : winid : start_idx : end_idx} info)
+ (local qf (vim.fn.getqflist {: id :items 1}))
+ (local fname (fn [e]
+ (if (not= 0 e.bufnr)
+ (vim.fn.bufname (. e :bufnr))
+ "")))
+ (local s (fn [line pattern]
+ (let [(result n) (line:gsub pattern "")]
+ (match n
+ nil line
+ _ result))))
+ (local prettify #(-> $1
+ (s "%c+%[[0-9:;<=>?]*[!\"#$%%&'()*+,-./]*[@A-Z%[%]^_`a-z{|}~]*;?[A-Z]?")))
+ (local pos (fn [e] (if (not= 0 e.lnum)
+ (.. e.lnum " col " e.col)
+ "")))
+ (local format (fn [e] (accumulate [l ""
+ _ word
+ (ipairs [(fname e) "|" (pos e) "| " e.text])]
+ (.. l word))))
+
+ (local items (fn [cfg] (. (vim.fn.getqflist cfg) :items)))
+
+ (icollect
+ [_ E (ipairs
+ (items
+ {:lines
+ (icollect [_ e (ipairs qf.items)]
+ (prettify e.text))}))]
+ (format E))))
(tset _G :P (lambda [...]
(let [inspected (icollect [_ v (ipairs [...])]
diff --git a/mut/neovim/fnl/conf/pkgs/cmp.fnl b/mut/neovim/fnl/conf/pkgs/cmp.fnl
index 97c0655..1edce94 100644
--- a/mut/neovim/fnl/conf/pkgs/cmp.fnl
+++ b/mut/neovim/fnl/conf/pkgs/cmp.fnl
@@ -1,20 +1,5 @@
(local cmp (require :cmp))
-(fn string-startswith? [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)))
-
- (iter start-list))
-
-(fn string-startswith-upper? [str]
- (local first-char (string.sub str 1 1))
- (= first-char (string.upper first-char)))
-
(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))
@@ -22,11 +7,8 @@
(local is_string (before:match "%s"))
(and (not= col 0) (= is_string nil)))
-
-(fn edit? []
- (local line (vim.fn.getcmdline))
- (not= nil (line:match "ed?i?t? %.*")))
-
+(fn edit? [line]
+ (not= nil (line:match "^ed?i?t? .*$")))
(fn enum [types key]
(. (. cmp types) key))
@@ -64,53 +46,31 @@
:sources (cmp.config.sources [{:name :nvim_lsp}
{:name :path}
{:name :luasnip}])})
+
+ ; This tries to emulate somewhat ido mode to find files
; todo sorting based on least recently used
(cmp.setup.cmdline
":"
- {:completion {:completeopt "menu,menuone,noinsert"}
- :matching {:disallow_fuzzy_matching false
- :disallow_fullfuzzy_matching false
- :disallow_partial_fuzzy_matching false
- :disallow_partial_matching false
- :disallow_prefix_unmatching false}
-
- :mapping (cmp.mapping.preset.cmdline {
- :<M-CR> (cmp.mapping
- (fn []
- (cmp.confirm {:select true :behavior cmp.ConfirmBehavior.Replace})
- (vim.api.nvim_feedkeys " " :c false)
- (vim.defer_fn cmp.complete 10))
- [:i :c])
- :<CR> (cmp.mapping
- (fn [fallback]
- (local entry (cmp.get_selected_entry))
- (if (or (= nil entry) (not (edit?)))
- (vim.schedule fallback)
- (do
- (cmp.confirm {:select true :behavior cmp.ConfirmBehavior.Replace})
- (if (entry.completion_item.label:match "%.*/$")
- (do
- (vim.defer_fn cmp.complete 10))
- (do
- (vim.schedule fallback))))))
- [:i :c])
- :<M-BS> {:c (fn [fallback]
- (if (not (edit?))
- (fallback)
- (do
- (local line (vim.fn.getcmdline))
- (local key (vim.api.nvim_replace_termcodes "<C-w>" true false true))
- (if (= nil (line:match "%.*/$"))
- (vim.api.nvim_feedkeys key :c false)
- (do
- (vim.api.nvim_feedkeys (.. key key) :c false)))
- (vim.defer_fn #(cmp.complete) 10))))}
- :<C-w> {:c (fn [fallback]
- (fallback)
- (vim.defer_fn #(cmp.complete) 10))}
- :<C-y> {:c (fn [fallback]
- (cmp.confirm {:select false})
- (vim.defer_fn #(cmp.complete) 10))}})
+ {:enabled (fn [] (local val (edit? (vim.fn.getcmdline)))
+ (if (not val)
+ (cmp.close))
+ val)
+ :completion {:completeopt "menu,menuone,noinsert"}
+ :mapping {:<CR> (cmp.mapping
+ (fn [fallback]
+ (local entry (cmp.get_selected_entry))
+ (local line (vim.fn.getcmdline))
+ (if (or (= nil entry) (not (edit? line)))
+ (do
+ (vim.schedule fallback))
+ (do
+ (cmp.confirm {:select true :behavior cmp.ConfirmBehavior.Replace})
+ (if (entry.completion_item.label:match "%.*/$")
+ (do
+ (vim.defer_fn cmp.complete 10))
+ (do
+ (vim.schedule fallback))))))
+ [:i :c])}
:sources (cmp.config.sources
[{:name :cmdline} {:name :path}])}
@@ -123,6 +83,6 @@
(let [map vim.keymap.set]
(map :n :<leader>xf (fn []
(vim.api.nvim_feedkeys (.. ":e " (vim.fn.getcwd)) :c false)
- (vim.schedule #(vim.api.nvim_feedkeys "/" :c false)))))
+ (vim.defer_fn #(vim.api.nvim_feedkeys "/" :c false) 10))))
(cmp-setup (require :cmp) true)
diff --git a/mut/neovim/fnl/conf/pkgs/harpoon.fnl b/mut/neovim/fnl/conf/pkgs/harpoon.fnl
deleted file mode 100644
index 3f5fc48..0000000
--- a/mut/neovim/fnl/conf/pkgs/harpoon.fnl
+++ /dev/null
@@ -1,39 +0,0 @@
-(local harpoon-mark (require :harpoon.mark))
-(local harpoon-ui (require :harpoon.ui))
-(fn make-harpoon [func]
- (fn []
- (func)
- (vim.cmd :redrawtabline)))
-
-(vim.keymap.set :n "[]" (make-harpoon (fn [] (harpoon-mark.add_file))))
-(vim.keymap.set :n "][" (make-harpoon (fn [] (harpoon-ui.toggle_quick_menu))))
-(vim.keymap.set :n "]]" (make-harpoon (fn [] (harpoon-ui.nav_next))))
-(vim.keymap.set :n "[[" (make-harpoon (fn [] (harpoon-ui.nav_prev))))
-
-(var use-numbers false)
-(local num [1 2 3 4 5])
-(local shortcuts ["+" "-" "<" ">" "\""])
-(fn print-use-numbers []
- (print (vim.inspect use-numbers)))
-
-(fn toggle-harpoon-mappings []
- (if (not use-numbers)
- (do
- ; (each [_ i (ipairs shortcuts)] ; (vim.keymap.del :n i))
- (vim.keymap.set :n "[+" (make-harpoon (fn [] (harpoon-ui.nav_file 1))))
- (vim.keymap.set :n "[-" (make-harpoon (fn [] (harpoon-ui.nav_file 2))))
- (vim.keymap.set :n "[<" (make-harpoon (fn [] (harpoon-ui.nav_file 3))))
- (vim.keymap.set :n "[>" (make-harpoon (fn [] (harpoon-ui.nav_file 4))))
- (vim.keymap.set :n "[\"" (make-harpoon (fn [] (harpoon-ui.nav_file 5))))
- (set use-numbers true))
- (do
- ; (each [_ s (ipairs shortcuts)] ; (vim.keymap.del :n s)
- (vim.keymap.set :n "[1" (make-harpoon (fn [] (harpoon-ui.nav_file 1))))
- (vim.keymap.set :n "[2" (make-harpoon (fn [] (harpoon-ui.nav_file 2))))
- (vim.keymap.set :n "[3" (make-harpoon (fn [] (harpoon-ui.nav_file 3))))
- (vim.keymap.set :n "[4" (make-harpoon (fn [] (harpoon-ui.nav_file 4))))
- (vim.keymap.set :n "[5" (make-harpoon (fn [] (harpoon-ui.nav_file 5))))
- (set use-numbers false))))
-
-(vim.api.nvim_create_user_command :H toggle-harpoon-mappings {})
-(toggle-harpoon-mappings)
diff --git a/mut/neovim/fnl/conf/pkgs/test.fnl b/mut/neovim/fnl/conf/pkgs/test.fnl
deleted file mode 100644
index 4f0bcc4..0000000
--- a/mut/neovim/fnl/conf/pkgs/test.fnl
+++ /dev/null
@@ -1,9 +0,0 @@
-(tset vim.g "test#strategy" :neovim)
-(tset vim.g "test#neovim#term_position" :botright)
-
-(vim.keymap.set :n :<leader>t ":TestNearest<CR>" {:silent true})
-(vim.keymap.set :n :<leader>C ":TestClass<CR>" {:silent true})
-(vim.keymap.set :n :<leader>T ":TestFile<CR>" {:silent true})
-(vim.keymap.set :n :<leader>a ":TestSuite<CR>" {:silent true})
-(vim.keymap.set :n :<leader>l ":TestLast<CR>" {:silent true})
-(vim.keymap.set :n :<leader>g ":TestVisit<CR>" {:silent true})
diff --git a/mut/neovim/fnl/conf/settings.fnl b/mut/neovim/fnl/conf/settings.fnl
index fc0ed3e..f7b52a6 100644
--- a/mut/neovim/fnl/conf/settings.fnl
+++ b/mut/neovim/fnl/conf/settings.fnl
@@ -58,10 +58,10 @@
relativenumber on
exrc on
secure on
- completeopt "menu,longest,preview"
+ ; completeopt "menu,longest,preview"
wmnu on
wop "pum"
- wildmode "list:longest"
+ ; wildmode "list:longest"
complete ".,w,k,kspell,b"
foldopen "block,hor,jump,mark,percent,quickfix,search,tag"
laststatus 3