summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Vink <>2023-04-16 09:59:19 +0200
committerMike Vink <>2023-04-16 09:59:19 +0200
commit65391314b5dfe5ef871929324046b7e13a288d02 (patch)
treeaddcf6cbf768c25d0a8e9d331f6883a5ecbc4e22
parent3c565e9b6e7c95f29507eb751bd1f951bc466425 (diff)
big changes?
-rw-r--r--fnl/conf/cmd.fnl65
-rw-r--r--fnl/conf/init.fnl1
-rw-r--r--fnl/conf/log.fnl37
-rw-r--r--fnl/conf/newtab/init.fnl7
-rw-r--r--fnl/conf/nix-develop/init.fnl72
-rw-r--r--fnl/conf/pkgs/harpoon.fnl1
-rw-r--r--fnl/conf/pkgs/heirline.fnl10
-rw-r--r--fnl/conf/pkgs/noice.fnl4
-rw-r--r--fnl/conf/settings.fnl1
-rw-r--r--init.fnl1
10 files changed, 56 insertions, 143 deletions
diff --git a/fnl/conf/cmd.fnl b/fnl/conf/cmd.fnl
deleted file mode 100644
index 6b89ff6..0000000
--- a/fnl/conf/cmd.fnl
+++ /dev/null
@@ -1,65 +0,0 @@
-(var buf nil)
-(var channel nil)
-
-(var static-buf nil)
-(var static-channel nil)
-
-(fn show-buf [b split]
- (local split-cmd split)
- (vim.cmd split-cmd)
- (local w (vim.api.nvim_get_current_win))
- (vim.api.nvim_win_set_buf w b)
- w)
-
-(fn hide-buf [b]
- (local wlist (vim.fn.win_findbuf b))
- (each [_ w (pairs wlist)]
- (vim.api.nvim_win_close w false)))
-
-(fn visible? [b]
- (if (or (= nil b) (not (vim.api.nvim_buf_is_valid b)))
- false)
- (local wlist (vim.fn.win_findbuf b))
- (print (vim.inspect wlist))
- (< 0 (length wlist)))
-
-(fn open-terminal [opts]
- (if (or (= nil buf) (not (vim.api.nvim_buf_is_valid buf)))
- (let [b (vim.api.nvim_create_buf false true)]
- (match b
- 0 :error
- _ (set buf b))))
- (show-buf (. opts :splitcmd))
- (if (= nil channel)
- (let [c (vim.fn.termopen [vim.o.shell]
- {:on_exit (fn []
- (set buf nil)
- (set channel nil))})]
- (match c
- 0 :error
- _ (set channel c)))))
-
-(fn cmd [cmd opts]
- (if (not (visible?)) (open-terminal {:splitcmd "vertical bo split"}))
- (vim.fn.chansend channel (.. cmd "\r")))
-
-(fn job [opts]
- (if (or (= nil static-buf) (not (vim.api.nvim_buf_is_valid static-buf)))
- (let [b (vim.api.nvim_create_buf false true)]
- (match b
- 0 :error
- _ (set static-buf b))))
- (if (= nil static-channel)
- (let [c (vim.api.nvim_open_term static-buf
- {:on_input (fn []
- (print :on_input))})]
- (match c
- 0 :error
- _ (set static-channel c))))
- (local command (or (. opts :cmd) (.. vim.o.shell " -c \"echo 'hi three'\"")))
- (if (not (visible? static-buf)) (show-buf static-buf "vertical bo split"))
- (vim.fn.chansend static-channel (.. command "\r")))
-
-(job {})
-(print static-buf)
-(print static-channel)
diff --git a/fnl/conf/init.fnl b/fnl/conf/init.fnl
index 6f8d882..d07293d 100644
--- a/fnl/conf/init.fnl
+++ b/fnl/conf/init.fnl
@@ -8,6 +8,7 @@
(require :conf.lsp)
(require :conf.events)
(require :conf.newtab)
+(require :conf.nix-develop)
;; (require :conf.cmd)
diff --git a/fnl/conf/log.fnl b/fnl/conf/log.fnl
deleted file mode 100644
index db86d58..0000000
--- a/fnl/conf/log.fnl
+++ /dev/null
@@ -1,37 +0,0 @@
-(local scratches {})
-(fn scratch-buffer [name ft]
- (fn setopt [buf opt value]
- (vim.api.nvim_buf_set_option buf opt value)
- buf)
-
- (fn track [buf]
- (tset scratches name buf)
- buf)
-
- (track (-> (vim.api.nvim_create_buf true false)
- (setopt :filetype ft)
- (setopt :buftype :nofile)
- (setopt :bufhidden :hide)
- (setopt :swapfile false))))
-
-(let [log (fn [...]
- (P [...]))]
- (vim.api.nvim_create_user_command :Scratch
- (fn [c]
- (let [name c.args]
- (fn exists? [buf]
- (not= buf nil))
-
- (fn get []
- (. scratches c.args))
-
- (fn goto [buf]
- (vim.api.nvim_set_current_buf buf))
-
- (let [buf (get)
- current (vim.api.nvim_get_current_buf)]
- (if (exists? buf) (goto buf)
- (goto (scratch-buffer name
- (vim.api.nvim_buf_get_option current
- :filetype)))))))
- {:complete log :nargs 1}))
diff --git a/fnl/conf/newtab/init.fnl b/fnl/conf/newtab/init.fnl
index 04096b2..fbf8e18 100644
--- a/fnl/conf/newtab/init.fnl
+++ b/fnl/conf/newtab/init.fnl
@@ -22,17 +22,12 @@
(actions.close prompt_buf)
(local selection
(action_state.get_selected_entry))
- (P selection)
(vim.cmd (.. :tabnew
(. selection
1)))
(vim.cmd (.. :tc
(. selection
- 1)))
- (vim.schedule (fn []
- (vim.cmd (.. :Telescope
- " "
- :find_files)))))))
+ 1))))))
:sorter (conf.generic_sorter opts)}))
(finder:find))
diff --git a/fnl/conf/nix-develop/init.fnl b/fnl/conf/nix-develop/init.fnl
index ddafb6a..62b0429 100644
--- a/fnl/conf/nix-develop/init.fnl
+++ b/fnl/conf/nix-develop/init.fnl
@@ -1,6 +1,6 @@
(local loop vim.loop)
-(var dev-env {})
+(var original-env {})
(local ignored-variables {:SHELL true
:BASHOPTS true
:HOME true
@@ -20,27 +20,30 @@
:TZ true
:UID true})
-(fn ignored? [key]
- (. ignored-variables (string.upper key)))
+(local separated-dirs {:PATH ":" :XDG_DATA_DIRS ":"})
-(fn split [str sep]
- (local l [])
- (each [m (str:gmatch "[^\r\n]+")]
- (P m)
- (table.insert l m))
- (P l))
+(fn set-env [key value]
+ (if (not (. original-env key))
+ (tset original-env key (or (. vim.env key) :nix-develop-nil)))
+ (local sep (. separated-dirs key))
+ (if sep
+ (do
+ (local suffix (or (. vim.env key) ""))
+ (tset vim.env key (.. value sep suffix)))
+ (tset vim.env key value)))
-(fn qf [title lines]
- (P lines)
- (vim.fn.setqflist [] " " {: title : lines})
- (vim.cmd :cope))
+(fn unload-env []
+ (each [k v (pairs original-env)]
+ (if (= v :nix-develop-nil)
+ (tset vim.env k nil)
+ (tset vim.env k v))))
+
+(fn ignored? [key]
+ (. ignored-variables (string.upper key)))
(fn exported? [Type]
(= Type :exported))
-(fn set-env [variables])
-(fn unload-env [])
-
(fn nix-develop [fargs]
(local cmd :nix)
(local fargs (or fargs []))
@@ -50,29 +53,34 @@
(var nix-print-dev-env "")
(local p (loop.spawn cmd {: args : stdio}
(fn [code signal]
- (vim.schedule (fn []
- (local json
- (vim.fn.json_decode nix-print-dev-env))
- (-> (accumulate [kvps {} key {: Type
- : value} (pairs json.variables)]
- (do
- (if (and (exported? Type)
- (not (ignored? key)))
- (tset kvps key value))
- kvps))
- (#(each [key value (pairs $1)]
- (set-env key value)))
- (#(set dev-env $1))))))))
+ (vim.notify (.. "nix-develop: exit code " code " "
+ signal)))))
(loop.read_start stdout
(fn [err data]
(assert (not err) err)
(if data
(set nix-print-dev-env (.. nix-print-dev-env data))
- (P {:msg "stdout end" : stdout})))))
-
-(nix-develop)
+ (do
+ (P {:msg "stdout end" : stdout})
+ (vim.schedule #(each [key {: type : value} (pairs (. (vim.fn.json_decode nix-print-dev-env)
+ :variables))]
+ (do
+ (if (and (exported? type)
+ (not (ignored? key)))
+ (do
+ (set-env key value)))))))))))
(vim.api.nvim_create_user_command :NixDevelop
(fn [ctx]
(nix-develop ctx.fargs))
{:nargs "*"})
+
+(vim.api.nvim_create_augroup :nix-develop {:clear true})
+(vim.api.nvim_create_autocmd [:DirChanged :VimEnter]
+ {:pattern ["*"]
+ :callback (fn [ctx]
+ (unload-env)
+ (if (= 1
+ (vim.fn.filereadable (.. ctx.file
+ :/flake.nix)))
+ (nix-develop)))})
diff --git a/fnl/conf/pkgs/harpoon.fnl b/fnl/conf/pkgs/harpoon.fnl
index 8d6138b..3f5fc48 100644
--- a/fnl/conf/pkgs/harpoon.fnl
+++ b/fnl/conf/pkgs/harpoon.fnl
@@ -17,7 +17,6 @@
(print (vim.inspect use-numbers)))
(fn toggle-harpoon-mappings []
- (print-use-numbers)
(if (not use-numbers)
(do
; (each [_ i (ipairs shortcuts)] ; (vim.keymap.del :n i))
diff --git a/fnl/conf/pkgs/heirline.fnl b/fnl/conf/pkgs/heirline.fnl
index b39bcf3..3579d9c 100644
--- a/fnl/conf/pkgs/heirline.fnl
+++ b/fnl/conf/pkgs/heirline.fnl
@@ -78,10 +78,20 @@
(string.rep (. self :sbar i) 2))
:hl {:fg (theme :syn :fun) :bg (theme :ui :bg)}})
+(local Nix
+ {:condition (fn [] vim.env.IN_NIX_SHELL)
+ :provider (fn [self]
+ (local purity vim.env.IN_NIX_SHELL)
+ (local name vim.env.name)
+ (.. "" purity "(" name ")"))
+ :hl {:fg (theme :syn :fun) :bold true :bg (theme :ui :bg_m3)}})
+
(local StatusLine [FileNameBlock
Space
DAPMessages
Align
+ Nix
+ Space
Ruler
Space
ScrollBar
diff --git a/fnl/conf/pkgs/noice.fnl b/fnl/conf/pkgs/noice.fnl
index a017714..46f0323 100644
--- a/fnl/conf/pkgs/noice.fnl
+++ b/fnl/conf/pkgs/noice.fnl
@@ -1,5 +1,7 @@
(local noice (require :noice))
-(noice.setup {:lsp {;; override markdown rendering so that **cmp** and other plugins use **Treesitter**
+(noice.setup {:views {:cmdline_popup {:border {:style :none :padding [1 3]}
+ :win_options {:winhighlight "NormalFloat:NormalFloat,FloatBorder:FloatBorder"}}}
+ :lsp {;; override markdown rendering so that **cmp** and other plugins use **Treesitter**
:override {[:vim.lsp.util.convert_input_to_markdown_lines] true
[:vim.lsp.util.stylize_markdown] true
[:cmp.entry.get_documentation] true}}
diff --git a/fnl/conf/settings.fnl b/fnl/conf/settings.fnl
index 8eb0c19..6537a0e 100644
--- a/fnl/conf/settings.fnl
+++ b/fnl/conf/settings.fnl
@@ -23,6 +23,7 @@
dirvish_mode ":sort | sort ,^.*[^/]$, r")
(settings
+ cmdheight 0
+shortmess "c"
+diffopt vertical
+isfname "@-@"
diff --git a/init.fnl b/init.fnl
index de501a2..7e82675 100644
--- a/init.fnl
+++ b/init.fnl
@@ -33,5 +33,4 @@
path (vim.fn.expand (.. config-path :/init.fnl))]
(uv.fs_event_start handle path {} #(vim.schedule build-init))
(vim.api.nvim_create_autocmd :VimLeavePre {:callback #(uv.close handle)})))
-
(require :conf)