summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmut/bin/window11
-rw-r--r--mut/neovim/fnl/conf/events.fnl12
-rw-r--r--mut/neovim/fnl/conf/init.fnl126
-rw-r--r--mut/neovim/fnl/conf/pkgs.fnl1
-rw-r--r--mut/neovim/fnl/conf/pkgs/lint.fnl6
-rw-r--r--mut/neovim/fnl/conf/pkgs/lspconfig.fnl16
-rw-r--r--profiles/core/neovim.nix6
7 files changed, 96 insertions, 82 deletions
diff --git a/mut/bin/window b/mut/bin/window
new file mode 100755
index 0000000..bd40a4c
--- /dev/null
+++ b/mut/bin/window
@@ -0,0 +1,11 @@
+#!/bin/sh
+PIPE=/tmp/window-fifo
+STDIN="$(cat -)"
+rm $PIPE
+mkfifo $PIPE
+echo "$STDIN" | tee $PIPE >/dev/null &
+if command -v st >/dev/null; then
+ st -e sh -c "<$PIPE ${*}" &
+else
+ tmux splitw sh -c "<$PIPE ${*}" &
+fi
diff --git a/mut/neovim/fnl/conf/events.fnl b/mut/neovim/fnl/conf/events.fnl
index f48f1b9..18d602e 100644
--- a/mut/neovim/fnl/conf/events.fnl
+++ b/mut/neovim/fnl/conf/events.fnl
@@ -20,12 +20,6 @@
:callback #(vim.schedule #(oil.open (vim.fn.getcwd)))})
(event
- :BufWritePost
- {:group "conf#events"
- :pattern ["*.rs"]
- :callback #(vim.cmd (.. "Compile! rustfmt " (vim.fn.expand "%")))})
-
-(event
:BufReadPost
{:pattern ["*"]
:callback (fn []
@@ -35,6 +29,12 @@
(vim.cmd "hi link TrailingWhitespace IncSearch"))
:group "conf#events"})
+(event
+ :BufWritePost
+ {:group "conf#events"
+ :callback #(do (local lint (require :lint)) (lint.try_lint) (vim.diagnostic.setloclist))})
+
+
(local session-file (.. vim.env.HOME "/.vimsession.vim"))
(event
:VimLeave
diff --git a/mut/neovim/fnl/conf/init.fnl b/mut/neovim/fnl/conf/init.fnl
index 2c0adfb..55b24b5 100644
--- a/mut/neovim/fnl/conf/init.fnl
+++ b/mut/neovim/fnl/conf/init.fnl
@@ -30,12 +30,12 @@
(map :n :<leader>q<BS> ":cclose<cr>")
(map :n :<leader>ll ":lopen<cr>")
(map :n :<leader>l<BS> ":lclose<cr>")
- (map :n :<M-space> ":cprev<cr>")
- (map :n :<C-M-space> ":cprev<cr>")
- (map :n :<C-space> ":cnext<cr>")
+ (map :n "<M-h>" cope)
+ (map :n "<M-j>" ":cnext<cr>")
+ (map :n "<M-k>" ":cprev<cr>")
+ (map :n :<M-l> ":Recompile<CR>")
(map :n :<C-x>
#(do
- (vim.fn.setreg "/" "Compile")
(vim.api.nvim_feedkeys
(vim.api.nvim_replace_termcodes
":Compile<up><c-f>" true false true)
@@ -44,7 +44,6 @@
(vim.cmd "let v:searchforward = 0")
(map :n :/ "/Compile.* " {:buffer true})
(map :n :? "?Compile.* " {:buffer true})))))
- (map :n :<C-e> ":Recompile<CR>")
(map :n "[q" ":cprevious<cr>")
(map :n "]q" ":cnext<cr>")
(map :n "[x" ":lprevious<cr>")
@@ -52,6 +51,8 @@
(map :n :<c-p> #(fzf.files))
(map :n :<leader>xp #(fzf.files))
(map :n "<leader>;" ":silent grep ")
+ (map :n "<leader>'" ":silent args `fd `<left>")
+ (map :n :<leader>xa #(fzf.args))
(map :n :<leader>xb #(fzf.buffers
{:keymap {:fzf {"ctrl-a" "select-all"
"alt-a" "deselect-all"}}
@@ -71,10 +72,6 @@
(local qf
(fn [{: id : title}]
(fn [lines]
- (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
@@ -82,63 +79,65 @@
_ 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 lines (icollect [_ l (ipairs lines)]
- (if (not= l "")
- (prettify l))))
- (local is-at-last-line (let [[n lnum & rest] (vim.fn.getcurpos)
- last-line (vim.api.nvim_buf_line_count 0)]
- (do
- (= lnum last-line))))
- (local is-qf (= (vim.opt_local.buftype:get) "quickfix"))
- (vim.fn.setqflist [] :a {: id : title : lines})
- (if (or
- (not is-qf)
- (and is-at-last-line is-qf))
- (vim.cmd ":cbottom")))))
+ (vim.schedule
+ #(do
+ (vim.fn.setqflist
+ [] :a
+ {: id : title
+ :lines
+ (icollect [l lines]
+ (do
+ (if (not= l "")
+ (prettify l))))})
+ (local is-qf (= (vim.opt_local.buftype:get) "quickfix"))
+ (local is-at-last-line (let [[row col] (vim.api.nvim_win_get_cursor 0)
+ last-line (vim.api.nvim_buf_line_count 0)]
+ (do
+ (= row last-line))))
+ (if (or
+ (not is-qf)
+ (and is-at-last-line is-qf))
+ (vim.cmd ":cbottom")))))))
(var last_job nil)
-(local job
+(local qfjob
(fn [cmd]
- (local title cmd)
+ (local title (table.concat cmd " "))
(vim.fn.setqflist [] " " {: title})
(local add2qf (qf (vim.fn.getqflist {:id 0 :title 1})))
- (local id
- (vim.fn.jobstart
- cmd
- {:on_stdout (fn [id data]
- (if data
- (add2qf data)))
- :on_stderr (fn [id data]
- (if data
- (add2qf data)))
- :on_exit (fn [id rc]
- (set last_job.finished true)
- (set winnr (vim.fn.winnr))
- (if (not= rc 0)
- (do
- (cope)
- (if (not= (vim.fn.winnr) winnr)
- (do
- (vim.notify "going back")
- (vim.cmd "wincmd p | cbot"))))
- (vim.notify (.. "\"" cmd "\" succeeded!"))))}))
(set
last_job
- {: cmd
- : id
- :finished false})))
+ (vim.system
+ cmd
+ {:stdout (fn [err data]
+ (if data
+ (add2qf (string.gmatch data "[^\n]+"))))
+ :stderr (fn [err data]
+ (if data
+ (add2qf (string.gmatch data "[^\n]+"))))}
+ (fn [obj]
+ (vim.schedule
+ #(do
+ (set winnr (vim.fn.winnr))
+ (if (not= obj.code 0)
+ (do
+ (cope)
+ (if (not= (vim.fn.winnr) winnr)
+ (do
+ (vim.notify (.. title " failed, going back"))
+ (vim.cmd "wincmd p | cbot"))
+ (vim.notify (.. title "failed, going back"))))
+ (vim.notify (.. "\"" title "\" succeeded!"))))))))))
(vim.api.nvim_create_user_command
:Compile
(fn [cmd]
- (job cmd.args))
+ (qfjob cmd.fargs))
+ {:nargs :* :bang true :complete :shellcmd})
+(vim.api.nvim_create_user_command
+ :Sh
+ (fn [cmd]
+ (qfjob [:sh :-c cmd.args]))
{:nargs :* :bang true :complete :shellcmd})
(vim.api.nvim_create_user_command
:Recompile
@@ -147,12 +146,21 @@
(vim.notify "nothing to recompile")
(if (not last_job.finished)
(vim.notify "Last job not finished")
- (job last_job.cmd))))
+ (qfjob last_job.cmd))))
{:bang true})
(vim.api.nvim_create_user_command
- :Abort
+ :Stop
(fn []
(if (not= nil last_job)
- (vim.fn.jobstop last_job.id))
- (vim.notify "killed job"))
+ (last_job:kill))
+ (vim.notify "stopped job"))
{:bang true})
+(vim.api.nvim_create_user_command
+ :Args
+ (fn [obj]
+ (if (not= 0 (length obj.fargs))
+ (vim.system
+ [:sh :-c obj.args]
+ {:stdin (vim.fn.argv)}
+ (fn [job] (vim.schedule #(if (not= job.code 0) (vim.notify (.. "Args " obj.args " failed"))))))))
+ {:nargs :* :bang true :complete :shellcmd})
diff --git a/mut/neovim/fnl/conf/pkgs.fnl b/mut/neovim/fnl/conf/pkgs.fnl
index 37ebc52..c48b40d 100644
--- a/mut/neovim/fnl/conf/pkgs.fnl
+++ b/mut/neovim/fnl/conf/pkgs.fnl
@@ -5,5 +5,6 @@
(require :conf.pkgs.venn)
(require :conf.pkgs.gitsigns)
(require :conf.pkgs.oil)
+(require :conf.pkgs.lint)
;; (require :conf.pkgs.lsp_lines)
;; (require :conf.pkgs.null-ls)
diff --git a/mut/neovim/fnl/conf/pkgs/lint.fnl b/mut/neovim/fnl/conf/pkgs/lint.fnl
new file mode 100644
index 0000000..3125103
--- /dev/null
+++ b/mut/neovim/fnl/conf/pkgs/lint.fnl
@@ -0,0 +1,6 @@
+(local lint (require :lint))
+(set
+ lint.linters_by_ft
+ {:markdown [:vale]
+ :sh [:shellcheck]})
+
diff --git a/mut/neovim/fnl/conf/pkgs/lspconfig.fnl b/mut/neovim/fnl/conf/pkgs/lspconfig.fnl
index 0a463ad..98dda2c 100644
--- a/mut/neovim/fnl/conf/pkgs/lspconfig.fnl
+++ b/mut/neovim/fnl/conf/pkgs/lspconfig.fnl
@@ -1,6 +1,8 @@
(local lspconfig (require :lspconfig))
(local configs (require :lspconfig.configs))
+(lspconfig.nil_ls.setup {})
+
(lspconfig.rust_analyzer.setup
{:autostart false
:settings
@@ -42,17 +44,3 @@
:lint {:enabled false
:arguments " --profile=production --write=all "
:path :ansible-lint}}}})
-
-;; (tset configs :fennel_language_server
-;; {:default_config {;; replace it with true path
-;; :cmd [:fennel-language-server]
-;; :filetypes [:fennel]
-;; :single_file_support true
-;; ;; source code resides in directory `fnl/`
-;; :root_dir (lspconfig.util.root_pattern :fnl)
-;; :settings {:fennel {:workspace {;; If you are using hotpot.nvim or aniseed,
-;; ;; make the server aware of neovim runtime files.
-;; :library (vim.api.nvim_list_runtime_paths)}
-;; :diagnostics {:globals [:vim]}}}}})
-;;
-;; (lspconfig.fennel_language_server.setup {:on_attach attach})
diff --git a/profiles/core/neovim.nix b/profiles/core/neovim.nix
index 6a47682..b760226 100644
--- a/profiles/core/neovim.nix
+++ b/profiles/core/neovim.nix
@@ -1,6 +1,4 @@
{
- inputs,
- config,
pkgs,
...
}: {
@@ -41,6 +39,8 @@
statix
fzf
bat
+ nil
+ shellcheck
];
plugins = with pkgs.vimPlugins; [
# highlighting
@@ -69,7 +69,7 @@
nvim-dap-ui
luasnip
vim-test
- vim-rest-console
+ nvim-lint
# cmp
nvim-cmp