summaryrefslogtreecommitdiff
path: root/fnl
diff options
context:
space:
mode:
authorMike Vink <>2023-04-02 22:27:44 +0200
committerMike Vink <>2023-04-02 22:27:44 +0200
commitcdab6351519ae8d0a5a5a869a79c6f1c1ee522b7 (patch)
tree6cd0a91cade14ba611933d932e4cd260c74b5e2c /fnl
parent6f9c6aed95fc9bc95125a41f0d67c88919b9d0d6 (diff)
fixup
Diffstat (limited to 'fnl')
-rw-r--r--fnl/conf/pkgs/harpoon.fnl22
-rw-r--r--fnl/conf/pkgs/heirline.fnl58
-rw-r--r--fnl/conf/settings.fnl3
3 files changed, 60 insertions, 23 deletions
diff --git a/fnl/conf/pkgs/harpoon.fnl b/fnl/conf/pkgs/harpoon.fnl
index 4bb21ec..5f15de0 100644
--- a/fnl/conf/pkgs/harpoon.fnl
+++ b/fnl/conf/pkgs/harpoon.fnl
@@ -1,10 +1,16 @@
(local harpoon-mark (require :harpoon.mark))
(local harpoon-ui (require :harpoon.ui))
-(vim.keymap.set :n "[]" (lambda [] (harpoon-mark.add_file)))
-(vim.keymap.set :n "]]" (lambda [] (harpoon-ui.nav_next)))
-(vim.keymap.set :n "[[" (lambda [] (harpoon-ui.nav_prev)))
-(vim.keymap.set :n "[+" (lambda [] (harpoon-ui.nav_file 1)))
-(vim.keymap.set :n "[-" (lambda [] (harpoon-ui.nav_file 2)))
-(vim.keymap.set :n "[<" (lambda [] (harpoon-ui.nav_file 3)))
-(vim.keymap.set :n "[>" (lambda [] (harpoon-ui.nav_file 4)))
-(vim.keymap.set :n "[\"" (lambda [] (harpoon-ui.nav_file 5)))
+(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))))
+(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))))
diff --git a/fnl/conf/pkgs/heirline.fnl b/fnl/conf/pkgs/heirline.fnl
index 35f69e3..9511dc6 100644
--- a/fnl/conf/pkgs/heirline.fnl
+++ b/fnl/conf/pkgs/heirline.fnl
@@ -88,12 +88,34 @@
(local harpoon (require :harpoon))
(local harpoon-mark (require :harpoon.mark))
-(local HarpoonMarks {:provider (lambda []
- (local marks (harpoon.get_mark_config))
- (table.concat (icollect [_ mark (ipairs marks.marks)]
- (do
- (vim.fn.pathshorten mark.filename)))
- " "))})
+(local harpoon-colors [(theme :syn :identifier)
+ (theme :syn :identifier)
+ (theme :syn :identifier)])
+
+(fn mark-component [i mark]
+ (utils.insert {} {:hl {:bold true :fg (. harpoon-colors i)}
+ :provider (.. :M i "(")}
+ {:hl {:fg (theme :syn :fun)}
+ :provider (vim.fn.pathshorten mark.filename)}
+ {:hl {:bold true :fg (. harpoon-colors i)} :provider ")"} Space))
+
+(local HarpoonMarks (utils.insert {:hl :TabLineSel}
+ {:provider " "
+ :hl {:fg (theme :syn :identifier)
+ :bold true}}
+ {:init (lambda [self]
+ (local mark-list
+ (. (harpoon.get_mark_config)
+ :marks))
+ (each [i mark (ipairs mark-list)]
+ (tset self i
+ (self:new (mark-component i
+ mark)
+ i)))
+ (while (> (length self)
+ (length mark-list))
+ (table.remove self (length self))))}
+ Align))
(local Tabpage
{:provider (lambda [self]
@@ -106,7 +128,7 @@
(.. "%" self.tabnr "T " self.tabnr " "))
:hl (lambda [self]
- (if (not (. self :is_active)) :TabLine :TabLineSel))})
+ (if (not self.is_active) :TabLine :TabLineSel))})
(fn active-tab-hrpn [self]
(local hl {})
@@ -122,12 +144,20 @@
hl
{})))
+(fn tab-visible-buffers [tab]
+ (local visible (vim.fn.tabpagebuflist tab))
+ (if (= visible 0)
+ []
+ visible))
+
(fn tab-harpoon-marks [tab]
- (icollect [_ buf (ipairs (accumulate [buffers [] _ buf (ipairs (vim.fn.tabpagebuflist tab))]
- (do
- (if (not (vim.tbl_contains buffers buf))
- (table.insert buffers buf))
- buffers)))]
+ (local visible (tab-visible-buffers tab))
+ (local tab-buffers (accumulate [buffers [] _ buf (ipairs visible)]
+ (do
+ (if (not (vim.tbl_contains buffers buf))
+ (table.insert buffers buf))
+ buffers)))
+ (icollect [_ buf (ipairs tab-buffers)]
(do
(local status (harpoon-mark.status buf))
(if (not= status "")
@@ -147,9 +177,9 @@
(local TabPages
{;; only show this component if there's 2 or more tabpages
:condition (lambda []
- (>= (length (vim.api.nvim_list_tabpages)) 2))})
+ (>= (length (vim.api.nvim_list_tabpages)) 1))})
-(local TabPages (utils.insert TabPages Align (utils.make_tablist Tabpage)
+(local TabPages (utils.insert TabPages (utils.make_tablist Tabpage)
TabpageClose))
(heirline.setup {:statusline StatusLine :tabline [HarpoonMarks TabPages]})
diff --git a/fnl/conf/settings.fnl b/fnl/conf/settings.fnl
index 9b63659..d9ada32 100644
--- a/fnl/conf/settings.fnl
+++ b/fnl/conf/settings.fnl
@@ -60,4 +60,5 @@
laststatus 3
winbar "%=%m %f"
hlsearch off
- clipboard "")
+ clipboard ""
+ showtabline 2)