summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Vink <>2023-04-18 13:21:48 +0200
committerMike Vink <>2023-04-18 13:21:48 +0200
commit358919a8607b3b0ff71113f191a8174ad210326d (patch)
treec6bb87f4f8e635e9604861ac916042986eeaf584
parent169a24f967067bf68957acf34a247ced7a6bb79d (diff)
fixup
-rw-r--r--fnl/conf/init.fnl3
-rw-r--r--fnl/conf/nix-develop/init.fnl59
-rw-r--r--fnl/conf/pkgs.fnl1
-rw-r--r--fnl/conf/pkgs/lspconfig.fnl11
-rw-r--r--fnl/conf/pkgs/noice.fnl4
-rw-r--r--fnl/conf/pkgs/venn.fnl18
6 files changed, 80 insertions, 16 deletions
diff --git a/fnl/conf/init.fnl b/fnl/conf/init.fnl
index 483b3f0..64502b2 100644
--- a/fnl/conf/init.fnl
+++ b/fnl/conf/init.fnl
@@ -28,7 +28,8 @@
(map :n "]q" ":cnext<cr>")
(map :n "[x" ":lprevious<cr>")
(map :n "]x" ":lnext<cr>")
- (map :n :<c-p> ":Telescope find_files<cr>"))
+ (map :n :<c-p> ":Telescope find_files<cr>")
+ (map :n "`<Backspace>" ":FocusDispatch "))
(tset _G :P (lambda [...]
(let [inspected (icollect [_ v (ipairs [...])]
diff --git a/fnl/conf/nix-develop/init.fnl b/fnl/conf/nix-develop/init.fnl
index 11ebe90..8b8be4e 100644
--- a/fnl/conf/nix-develop/init.fnl
+++ b/fnl/conf/nix-develop/init.fnl
@@ -44,7 +44,45 @@
(fn exported? [Type]
(= Type :exported))
-(fn nix-develop [fargs]
+(fn handle-shellhook [shellhook] ; (P :handle-shellhook shellhook)
+ (var shellhook-env "")
+ (local stdin (loop.new_pipe))
+ (local stdout (loop.new_pipe))
+ (local p (loop.spawn :bash {:stdio [stdin stdout nil]}
+ (fn [code signal]
+ (vim.notify (.. "shellhook: exit code " code " "
+ signal)))))
+ (loop.read_start stdout
+ (fn [err data]
+ (assert (not err) err)
+ (if data
+ (set shellhook-env (.. shellhook-env data))
+ (do
+ (if (not= shellhook-env "")
+ (vim.schedule (fn []
+ (local json
+ (vim.fn.json_decode shellhook-env))
+ ; (P json)
+ (each [key value (pairs json)]
+ (set-env key value)))))))))
+ (stdin:write (.. shellhook "jq -n 'env'\n\n"))
+ (stdin:close))
+
+(fn handle-nix-print-dev-env [str]
+ (vim.schedule (fn []
+ (local json (. (vim.fn.json_decode str) :variables))
+ (-> (icollect [key {: type : value} (pairs json)]
+ (do
+ (if (and (exported? type) (not (ignored? key)))
+ (set-env key value))
+ (if (= key :shellHook)
+ value)))
+ (#(each [_ shellhook (ipairs $1)]
+ (handle-shellhook shellhook)))))))
+
+(fn nix-develop [fargs unload]
+ (if unload
+ (unload-env))
(local cmd :nix)
(local fargs (or fargs []))
(local args [:print-dev-env :--json (unpack fargs)])
@@ -53,27 +91,22 @@
(var nix-print-dev-env "")
(local p (loop.spawn cmd {: args : stdio}
(fn [code signal]
- (vim.notify (.. "nix-develop: exit code " code " "
- signal)))))
+ (if (not= code 0)
+ (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))
(do
- (P {:msg "stdout end" : stdout})
+ (vim.notify "nix-develop: stdout end")
(if (not= nix-print-dev-env "")
- (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))))))))))))
+ (handle-nix-print-dev-env nix-print-dev-env)))))))
(vim.api.nvim_create_user_command :NixDevelop
(fn [ctx]
- (nix-develop ctx.fargs))
+ (nix-develop ctx.fargs true))
{:nargs "*"})
(vim.api.nvim_create_augroup :nix-develop {:clear true})
@@ -84,4 +117,4 @@
(if (= 1
(vim.fn.filereadable (.. ctx.file
:/flake.nix)))
- (nix-develop)))})
+ (nix-develop false)))})
diff --git a/fnl/conf/pkgs.fnl b/fnl/conf/pkgs.fnl
index df7c974..5de2528 100644
--- a/fnl/conf/pkgs.fnl
+++ b/fnl/conf/pkgs.fnl
@@ -13,3 +13,4 @@
(require :conf.pkgs.heirline)
(require :conf.pkgs.gitsigns)
(require :conf.pkgs.harpoon)
+(require :conf.pkgs.venn)
diff --git a/fnl/conf/pkgs/lspconfig.fnl b/fnl/conf/pkgs/lspconfig.fnl
index af232ba..c2803cd 100644
--- a/fnl/conf/pkgs/lspconfig.fnl
+++ b/fnl/conf/pkgs/lspconfig.fnl
@@ -10,6 +10,17 @@
(vim.fn.getcwd))
:on_attach attach})
+(local pid (vim.fn.getpid))
+(lspconfig.omnisharp.setup {:cmd [:OmniSharp
+ :--languageserver
+ :--hostPID
+ (tostring pid)]
+ :handlers {[:textDocument/definition] (. (require :omnisharp_extended)
+ :handler)}
+ :root_dir (lspconfig.util.root_pattern :.git
+ (vim.fn.getcwd))
+ :on_attach attach})
+
(lspconfig.gopls.setup {:root_dir (lspconfig.util.root_pattern :.git
(vim.fn.getcwd))
:on_attach attach
diff --git a/fnl/conf/pkgs/noice.fnl b/fnl/conf/pkgs/noice.fnl
index 46f0323..cce1937 100644
--- a/fnl/conf/pkgs/noice.fnl
+++ b/fnl/conf/pkgs/noice.fnl
@@ -7,7 +7,7 @@
[:cmp.entry.get_documentation] true}}
:messages {; NOTE: If you enable messages then the cmdline is enabled automatically.
; This is a current Neovim limitation.
- :enabled false
+ :enabled true
; enables the Noice messages UI
:view :mini
; default view for messages
@@ -15,7 +15,7 @@
; view for errors
:view_warn :mini
; view for warnings
- :view_history :messages
+ :view_history :mini
; view for :messages
:view_search :virtualtext}
; view for search count messages. Set to `false` to disable}
diff --git a/fnl/conf/pkgs/venn.fnl b/fnl/conf/pkgs/venn.fnl
new file mode 100644
index 0000000..064e84e
--- /dev/null
+++ b/fnl/conf/pkgs/venn.fnl
@@ -0,0 +1,18 @@
+;; venn.nvim: enable or disable keymappings
+(fn toggle-venn []
+ (if (not vim.b.venn_enabled)
+ (do
+ (set vim.b.venn_enabled true)
+ (vim.cmd "setlocal ve=all") ; draw a line on HJKL keystokes
+ (vim.keymap.set [:n] :J "<C-v>j:VBox<CR>" {:noremap true :buffer 0})
+ (vim.keymap.set [:n] :K "<C-v>k:VBox<CR>" {:noremap true :buffer 0})
+ (vim.keymap.set [:n] :L "<C-v>l:VBox<CR>" {:noremap true :buffer 0})
+ (vim.keymap.set [:n] :H "<C-v>h:VBox<CR>" {:noremap true :buffer 0}) ; draw a box by pres]sing "f" with visual selection)
+ (vim.keymap.set [:v] :f ":VBox<CR>" {:noremap true :buffer 0}))
+ (do
+ (vim.cmd "setlocal ve=")
+ (vim.cmd "mapclear <buffer>")
+ (set vim.b.venn_enabled nil))))
+
+; toggle keymappings for venn using <leader>v)
+(vim.keymap.set [:n] :<leader>v toggle-venn {:noremap true})