summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Vink <mike1994vink@gmail.com>2022-11-22 01:02:29 +0100
committerMike Vink <mike1994vink@gmail.com>2022-11-22 01:02:29 +0100
commitccc185d43e03db06fbb679770b164c2eab6b6b49 (patch)
tree47dc3e458d21425df8f745ead05e2ec7fb2bd436
parentd8c08728465ef5679d771f01d5ce84fb1ddb9096 (diff)
messing around...
-rw-r--r--home.nix1
-rw-r--r--neovim/fnl/conf/build-init.fnl0
-rw-r--r--neovim/fnl/conf/init.fnl3
-rw-r--r--neovim/fnl/conf/log.fnl28
-rw-r--r--neovim/fnl/conf/lsp.fnl43
-rw-r--r--neovim/fnl/conf/macros.fnl6
-rw-r--r--neovim/fnl/conf/pkgs.fnl1
-rw-r--r--neovim/fnl/conf/pkgs/cmp.fnl28
-rw-r--r--neovim/fnl/conf/pkgs/null-ls.fnl17
9 files changed, 110 insertions, 17 deletions
diff --git a/home.nix b/home.nix
index 1c90dde..29a4f45 100644
--- a/home.nix
+++ b/home.nix
@@ -99,6 +99,7 @@
yaml-language-server
alejandra
statix
+ fnlfmt
];
extraConfig = "
lua <<LUA
diff --git a/neovim/fnl/conf/build-init.fnl b/neovim/fnl/conf/build-init.fnl
deleted file mode 100644
index e69de29..0000000
--- a/neovim/fnl/conf/build-init.fnl
+++ /dev/null
diff --git a/neovim/fnl/conf/init.fnl b/neovim/fnl/conf/init.fnl
index 4d10062..217614f 100644
--- a/neovim/fnl/conf/init.fnl
+++ b/neovim/fnl/conf/init.fnl
@@ -1,3 +1,5 @@
+(import-macros {: P} :conf.macros)
+
(tset (. vim "g") "mapleader" " ")
(tset (. vim "g") "maplocalleader" " ")
@@ -7,4 +9,5 @@
(ts.setup
{:highlight {:enable true}}))
+(require :conf.lsp)
(require :conf.pkgs)
diff --git a/neovim/fnl/conf/log.fnl b/neovim/fnl/conf/log.fnl
new file mode 100644
index 0000000..4507518
--- /dev/null
+++ b/neovim/fnl/conf/log.fnl
@@ -0,0 +1,28 @@
+(import-macros {: P} :conf.macros)
+
+(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/neovim/fnl/conf/lsp.fnl b/neovim/fnl/conf/lsp.fnl
new file mode 100644
index 0000000..8cd4d53
--- /dev/null
+++ b/neovim/fnl/conf/lsp.fnl
@@ -0,0 +1,43 @@
+(fn map-to-capabilities [{: client : buf}]
+ (fn bufoption [name value]
+ (vim.api.nvim_buf_set_option buf name value))
+
+ (fn bufmap [mode key cb]
+ (vim.keymap.set mode key cb {:silent true :noremap true :buffer buf}))
+
+ (fn lspdo [action]
+ (. vim.lsp action))
+
+ (fn use [cpb]
+ (match cpb
+ :completion (bufoption :omnifunc "v:lua.vim.lsp.omnifunc")
+ :rename (bufmap :n :<leader>gr (lspdo :rename))
+ :signature_help (bufmap :n :<leader>gs (lspdo :signature_help))
+ :goto_definition (bufmap :n :<leader>gd (lspdo :definition))
+ :declaration (bufmap :n :<leader>gD (lspdo :declaration))
+ :implementation (bufmap :n :<leader>gi (lspdo :implementation))
+ :find_references (bufmap :n :<leader>gi (lspdo :references))
+ :document_symbol (bufmap :n :<leader>gds (lspdo :workspace_symbol))
+ :code_action (bufmap :n :<leader>ga (lspdo :code_action))
+ :document_range_formatting (bufmap :v :<leader>gq
+ (lspdo :range_formatting))
+ :hover (bufoption :keywordprg ":LspHover")
+ :documentFormattingProvider ((fn []
+ (bufoption :formatexpr
+ "v:lua.vim.lsp.format()")
+ (bufmap :n :<leader>gq
+ #(vim.lsp.buf.format {:async true}))))))
+
+ (each [cpb enabled? (pairs client.server_capabilities)]
+ (if enabled?
+ (use cpb))))
+
+(fn attach [client buf]
+ (fn P [p]
+ (print (vim.inspect p))
+ p)
+
+ (-> {: client : buf}
+ (map-to-capabilities)))
+
+{: attach}
diff --git a/neovim/fnl/conf/macros.fnl b/neovim/fnl/conf/macros.fnl
index fe10ed3..80568b6 100644
--- a/neovim/fnl/conf/macros.fnl
+++ b/neovim/fnl/conf/macros.fnl
@@ -21,4 +21,8 @@
[a# "false"] (tset (. vim "opt") k# false)
[a# b#] (tset (. vim "opt") k# v#)))))
-{: settings}
+(fn P [p]
+ `(print (vim.inspect ,p)))
+
+{: settings
+ : P}
diff --git a/neovim/fnl/conf/pkgs.fnl b/neovim/fnl/conf/pkgs.fnl
index 77b3e73..df59b09 100644
--- a/neovim/fnl/conf/pkgs.fnl
+++ b/neovim/fnl/conf/pkgs.fnl
@@ -1 +1,2 @@
(require :conf.pkgs.cmp)
+(require :conf.pkgs.null-ls)
diff --git a/neovim/fnl/conf/pkgs/cmp.fnl b/neovim/fnl/conf/pkgs/cmp.fnl
index c31cb02..db3cbf9 100644
--- a/neovim/fnl/conf/pkgs/cmp.fnl
+++ b/neovim/fnl/conf/pkgs/cmp.fnl
@@ -1,18 +1,14 @@
(let [cmp (require :cmp)
luasnip (require :luasnip)
- snip (fn [args] (luasnip.lsp_expand (. args :body)))]
-
- (cmp.setup
- {:snippet {:expand snip}
- :completion {:autocomplete false}
- :mapping
- (cmp.mapping.preset.insert
- {"<C-b>" (cmp.mapping.scroll_docs -4)
- "<C-f>" (cmp.mapping.scroll_docs 4)
- "<C-A>" (cmp.mapping.complete)
- "<C-e>" (cmp.mapping.confirm {:select true})})
- :sources (cmp.config.sources
- [{:name :conjure}
- {:name :nvim_lsp}
- {:name :path}
- {:name :luasnip}])}))
+ snip (fn [args]
+ (luasnip.lsp_expand (. args :body)))]
+ (cmp.setup {:snippet {:expand snip}
+ :completion {:autocomplete false}
+ :mapping (cmp.mapping.preset.insert {:<C-b> (cmp.mapping.scroll_docs -4)
+ :<C-f> (cmp.mapping.scroll_docs 4)
+ :<C-A> (cmp.mapping.complete)
+ :<C-e> (cmp.mapping.confirm {:select true})})
+ :sources (cmp.config.sources [{:name :conjure}
+ {:name :nvim_lsp}
+ {:name :path}
+ {:name :luasnip}])}))
diff --git a/neovim/fnl/conf/pkgs/null-ls.fnl b/neovim/fnl/conf/pkgs/null-ls.fnl
new file mode 100644
index 0000000..45a507d
--- /dev/null
+++ b/neovim/fnl/conf/pkgs/null-ls.fnl
@@ -0,0 +1,17 @@
+(fn reload [mod]
+ (fn loaded? [mod]
+ (not= (. package.loaded mod) nil))
+
+ (fn unload [mod]
+ (tset package.loaded mod nil))
+
+ (if (loaded? mod) (unload mod))
+ (require mod))
+
+(let [null-ls (require :null-ls)]
+ (null-ls.setup {:update_on_insert false
+ :on_attach (. (reload :conf.lsp) :attach)
+ :sources [null-ls.builtins.formatting.black
+ null-ls.builtins.formatting.raco_fmt
+ null-ls.builtins.formatting.alejandra
+ null-ls.builtins.formatting.fnlfmt]}))