summaryrefslogtreecommitdiff
path: root/mut
diff options
context:
space:
mode:
authorMike Vink <59492084+ivi-vink@users.noreply.github.com>2024-12-12 22:41:27 +0000
committerMike Vink <59492084+ivi-vink@users.noreply.github.com>2024-12-12 22:41:27 +0000
commitaa5794e7e70b63393043a09a49e16a5f1235aae3 (patch)
treef17a060cc36ae0f4e3d32cc6a17e77589b99170d /mut
parent33e45ed710d478e01db665d4355e9f4b51ecc3c0 (diff)
push again for once
Diffstat (limited to 'mut')
-rwxr-xr-xmut/bin/xdg-open2
-rwxr-xr-xmut/bin/xdg-open-pipe9
l---------mut/lf/icons2
-rw-r--r--mut/neovim/lua/my/events.lua39
-rw-r--r--mut/neovim/lua/my/init.lua176
-rw-r--r--mut/neovim/lua/my/lsp.lua47
-rw-r--r--mut/neovim/lua/my/packages/luasnip.lua5
7 files changed, 228 insertions, 52 deletions
diff --git a/mut/bin/xdg-open b/mut/bin/xdg-open
new file mode 100755
index 0000000..af5b213
--- /dev/null
+++ b/mut/bin/xdg-open
@@ -0,0 +1,2 @@
+#!/bin/bash
+echo "$@" | tee "$HOME/.xdg-open-pipe"
diff --git a/mut/bin/xdg-open-pipe b/mut/bin/xdg-open-pipe
new file mode 100755
index 0000000..7ae22e1
--- /dev/null
+++ b/mut/bin/xdg-open-pipe
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+pipe="$HOME/.xdg-open-pipe"
+rm "$pipe"
+mkfifo "$pipe"
+while true; do
+ {
+ /nix/store/zcw13r2mmpzlnv2yvfl13mcpky3hivq1-system-path/bin/xdg-open "$(cat "$pipe")"
+} >/dev/null 2>&1
+done
diff --git a/mut/lf/icons b/mut/lf/icons
index e313a59..9c21023 120000
--- a/mut/lf/icons
+++ b/mut/lf/icons
@@ -1 +1 @@
-/nix/store/bfam7g4dqxwxkg8lnar25n5b4497ir15-home-manager-files/.config/lf/icons \ No newline at end of file
+/nix/store/lzsjy22l8zq0gagapm0zwgia3di6l66j-home-manager-files/.config/lf/icons \ No newline at end of file
diff --git a/mut/neovim/lua/my/events.lua b/mut/neovim/lua/my/events.lua
index 599c3ae..933ba19 100644
--- a/mut/neovim/lua/my/events.lua
+++ b/mut/neovim/lua/my/events.lua
@@ -67,6 +67,8 @@ event(
})
end})
+-- filetypes
+
event(
"FileType", {
group="conf#events",
@@ -79,3 +81,40 @@ event(
})
end,
})
+
+event(
+ "FileType", {
+ group="conf#events",
+ pattern={ "python" },
+ callback=function(ev)
+ vim.lsp.start({
+ name="basedpyright",
+ cmd={ "basedpyright-langserver", "--stdio" },
+ settings={
+ basedpyright = {
+ analysis = {
+ autoSearchPaths = true,
+ diagnosticMode = "openFilesOnly",
+ useLibraryCodeForTypes = true,
+ autoImportCompletions = true,
+ inlayHints = {
+ variableTypes = true,
+ callArgumentNames = true,
+ functionReturnTypes = true,
+ genericTypes = true,
+ },
+ },
+ },
+ },
+ root_dir=vim.fs.root(ev.buf, {
+ 'pyproject.toml',
+ 'setup.py',
+ 'setup.cfg',
+ 'requirements.txt',
+ 'Pipfile',
+ 'pyrightconfig.json',
+ '.git',
+ })
+ })
+ end,
+ })
diff --git a/mut/neovim/lua/my/init.lua b/mut/neovim/lua/my/init.lua
index 9efb4c8..5be4952 100644
--- a/mut/neovim/lua/my/init.lua
+++ b/mut/neovim/lua/my/init.lua
@@ -211,7 +211,7 @@ end
vim.api.nvim_create_user_command(
"Sh",
function(cmd)
- local thunk = function() qfjob({ "zshcmd", cmd.args }, nil) end
+ local thunk = function() qfjob({ "nu", "--commands", cmd.args }, nil) end
last_job_thunk = thunk
thunk()
end,
@@ -242,6 +242,121 @@ vim.api.nvim_create_user_command(
end
end, {bang=true})
+local browse_git_remote = function(fugitive_data)
+ local path = fugitive_data.path
+ if not path then
+ local bufname = vim.fn.bufname("%")
+ if vim.startswith(bufname,"oil://") then
+ local d = "oil://" .. vim.fs.dirname(fugitive_data.git_dir) .. "/"
+ path = bufname:sub(d:len()+1, bufname:len())
+ end
+ end
+ assert(path)
+
+ local home, org, project, repo = "", ""
+ if vim.startswith(fugitive_data.remote, "git@") then
+ home, repo = fugitive_data.remote:match("git@([^:]+):(.*)%.git")
+ if not (home and repo) then
+ home, org, project, repo = fugitive_data.remote:match("git@([^:]+):.*/(.*)/(.*)/(.*)")
+ end
+ end
+ assert((home and org and project and repo) or (home and repo))
+
+-- (.. "https://" home "/" repo "/src/" commit "/" (or oilpath path ""))
+-- [path "blob"]
+-- (.. "https://" home "/" repo "/src/" commit "/" path)
+-- [path "commit"]
+-- (.. "https://" home "/" repo "/commits/" commit)
+-- [path "ref"]
+-- (.. "https://" home "/" repo "/commits/" commit)))
+ local urls = {
+ ["bitbucket.org"] = {
+ ["tree"] = function(home, org, project, repo)
+ return "https://" .. home .. "/" .. repo .. "/src/" .. fugitive_data.commit .. "/" .. path
+ end,
+ ["blob"] = function(home, org, project, repo)
+ return "https://" .. home .. "/" .. repo .. "/src/" .. fugitive_data.commit .. "/" .. path
+ end,
+ ["commit"] = function(home, org, project, repo)
+ return "https://" .. home .. "/" .. repo .. "/commits/" .. fugitive_data.commit
+ end,
+ ["ref"] = function(home, org, project, repo)
+ return "https://" .. home .. "/" .. repo .. "/commits/" .. fugitive_data.commit
+ end,
+ },
+-- (.. "https://" home "/" org "/_git/" repo "?version=GB" commit "&path=/" (or oilpath path ""))
+-- [path "blob"]
+-- (.. "https://" home "/" org "/_git/" repo "?version=GB" commit "&path=/" path)
+-- [path "commit"]
+-- (.. "https://" home "/" org "/_git/" repo "/commit/" commit)
+-- [path "ref"]
+-- (.. "https://" home "/" org "/_git/" repo "/commit/" commit)))
+ ["dev.azure.com"] = {
+ ["tree"] = function(home, org, project, repo)
+ return "https://" .. home .. "/" .. org .. "/_git/" .. repo .. "?version=GB" .. fugitive_data.commit .. "&path=/" .. path
+ end,
+ ["blob"] = function(home, org, project, repo)
+ return "https://" .. home .. "/" .. org .. "/_git/" .. repo .. "?version=GB" .. fugitive_data.commit .. "&path=/" .. path
+ end,
+ ["commit"] = function(home, org, project, repo)
+ return "https://" .. home .. "/" .. org .. "/_git/" .. repo .. "/commit/" .. fugitive_data.commit
+ end,
+ ["ref"] = function(home, org, project, repo)
+ return "https://" .. home .. "/" .. org .. "/_git/" .. repo .. "/commit/" .. fugitive_data.commit
+ end,
+ },
+-- (where ["gitlab.com" repo])
+-- (do
+-- (case [path type]
+-- ["" "tree"]
+-- (.. "https://" home "/" repo "/-/tree/" commit "/" (or oilpath ""))
+-- [path "commit"]
+-- (.. "https://" home "/" repo "/-/commit/" commit)
+-- [path "ref"]
+-- (.. "https://" home "/" repo "/-/commit/" commit)
+-- [path "blob"]
+-- (.. "https://" home "/" repo "/-/blob/" commit "/" path)))
+ ["gitlab.com"] = {
+ ["tree"] = function(home, org, project, repo)
+ return "https://" .. home .. "/" .. repo .. "/-/tree/" .. fugitive_data.commit .. "/" .. path
+ end,
+ ["blob"] = function(home, org, project, repo)
+ return "https://" .. home .. "/" .. repo .. "/-/blob/" .. fugitive_data.commit .. "/" .. path
+ end,
+ ["commit"] = function(home, org, project, repo)
+ return "https://" .. home .. "/" .. repo .. "/-/commit/" .. fugitive_data.commit
+ end,
+ ["ref"] = function(home, org, project, repo)
+ return "https://" .. home .. "/" .. repo .. "/-/commit/" .. fugitive_data.commit
+ end,
+ },
+-- ["" "tree"]
+-- (.. "https://" home "/" repo "/tree/" commit "/" (or oilpath ""))
+-- [path "blob"]
+-- (.. "https://" home "/" repo "/blob/" commit "/" path)))))
+-- [path "commit"]
+-- (.. "https://" home "/" repo "/commit/" commit)
+-- [path "ref"]
+-- (.. "https://" home "/" repo "/commit/" commit)
+ ["github.com"] = {
+ ["tree"] = function(home, org, project, repo)
+ return "https://" .. home .. "/" .. repo .. "/tree/" .. fugitive_data.commit .. "/" .. path
+ end,
+ ["blob"] = function(home, org, project, repo)
+ return "https://" .. home .. "/" .. repo .. "/blob/" .. fugitive_data.commit .. "/" .. path
+ end,
+ ["commit"] = function(home, org, project, repo)
+ return "https://" .. home .. "/" .. repo .. "/commit/" .. fugitive_data.commit
+ end,
+ ["ref"] = function(home, org, project, repo)
+ return "https://" .. home .. "/" .. repo .. "/commit/" .. fugitive_data.commit
+ end,
+ },
+ }
+
+ return urls[home][fugitive_data.type](home, org, project, repo)
+end
+
-- (fn browse_git_remote
-- [data]
-- (P data)
@@ -329,6 +444,8 @@ vim.api.nvim_create_user_command(
-- (fn [{: args}] (vim.system ["xdg-open" args] {} (fn [])))
-- {:nargs 1})
--
+vim.g.fugitive_browse_handlers = { browse_git_remote }
+
-- (set vim.g.fugitive_browse_handlers
-- [browse_git_remote])
@@ -357,8 +474,7 @@ function paste()
}
end
function xclip(lines)
- vim.system({"xclip"}, {text= true, stdin=lines}, function(exit) end)
- vim.system({"xclip", "-selection", "clipboard"}, {text= true, stdin=lines}, function(exit) end)
+ vim.system({ "nu", "--commands", "xclip -f -sel c | xclip"}, {stdin=lines, text=true}, nil)
end
vim.g.clipboard = {
name = "OSC 52",
@@ -372,6 +488,60 @@ vim.g.clipboard = {
require("my.events")
require("my.packages")
+-- require('render-markdown').setup ({
+-- opts = {
+-- file_types = { "markdown", "Avante" },
+-- },
+-- ft = { "markdown", "Avante" },})
+require('avante_lib').load()
+-- require('copilot').setup {}
+require('avante').setup ({
+ provider = "openai",
+ openai = {
+ model = "gpt-4o",
+ },
+ behaviour = {
+ auto_suggestions = false,
+ auto_set_highlight_group = true,
+ auto_set_keymaps = true,
+ auto_apply_diff_after_generation = false,
+ support_paste_from_clipboard = false,
+ },
+ mappings = {
+ --- @class AvanteConflictMappings
+ diff = {
+ ours = "co",
+ theirs = "ct",
+ all_theirs = "ca",
+ both = "cb",
+ cursor = "cc",
+ next = "]x",
+ prev = "[x",
+ },
+ suggestion = {
+ accept = "<M-l>",
+ next = "<M-]>",
+ prev = "<M-[>",
+ dismiss = "<C-]>",
+ },
+ jump = {
+ next = "]]",
+ prev = "[[",
+ },
+ submit = {
+ normal = "<CR>",
+ insert = "<C-s>",
+ },
+ sidebar = {
+ apply_all = "A",
+ apply_cursor = "a",
+ switch_windows = "<Tab>",
+ reverse_switch_windows = "<S-Tab>",
+ },
+ },
+})
+
+
-- (local
-- draw
-- (fn [toggle]
diff --git a/mut/neovim/lua/my/lsp.lua b/mut/neovim/lua/my/lsp.lua
index ff09277..3097c58 100644
--- a/mut/neovim/lua/my/lsp.lua
+++ b/mut/neovim/lua/my/lsp.lua
@@ -34,43 +34,6 @@ local capability_map = {
local M = {}
--- (fn map-to-capabilities [{: client : buf}]
--- (fn use [cpb]
--- (match cpb
---
--- (each [cpb enabled? (pairs client.server_capabilities)]
--- (if enabled?
--- (use cpb)))
--- {: client : buf})
-
--- (fn register-handlers [{: client : buf}]
--- (tset (. client :handlers) :textDocument/publishDiagnostics
--- (vim.lsp.with
--- (fn [_ result ctx config]
--- (vim.lsp.diagnostic.on_publish_diagnostics _ result ctx
--- config)
--- (vim.diagnostic.setloclist {:open false}))
--- {:virtual_text false
--- :underline true
--- :update_in_insert false
--- :severity_sort true}))
--- {: client : buf})
-
--- (var format-on-save true)
--- (fn toggle-format-on-save []
--- (set format-on-save (not format-on-save)))
--- (vim.api.nvim_create_user_command :LspToggleOnSave toggle-format-on-save {:nargs 1 :complete (fn [] [:format])})
-
--- (fn events [{: client : buf}]
--- (match client.server_capabilities
--- {:documentFormattingProvider true}
--- (vim.api.nvim_create_autocmd
--- :BufWritePre
--- {:group
--- (vim.api.nvim_create_augroup :format-events {:clear true})
--- :buffer buf
--- :callback #(if format-on-save (vim.lsp.buf.format))})))
-
M.attach = function (ev)
vim.iter(ev.client.server_capabilities)
:each(function(c)
@@ -79,14 +42,4 @@ M.attach = function (ev)
end)
end
--- (fn attach [cb]
--- (-> cb
--- (register-handlers)
--- (map-to-capabilities)
--- (events)))
--- (fn lsp-attach-event [ev]
--- (local client (vim.lsp.get_client_by_id ev.data.client_id))
--- (local buf ev.buf)
--- (attach {: client : buf}))
- -- {: attach : lsp-attach-event}
return M
diff --git a/mut/neovim/lua/my/packages/luasnip.lua b/mut/neovim/lua/my/packages/luasnip.lua
index 0362d94..338b343 100644
--- a/mut/neovim/lua/my/packages/luasnip.lua
+++ b/mut/neovim/lua/my/packages/luasnip.lua
@@ -37,5 +37,8 @@ end, {silent=true})
ls.add_snippets(
"go", {
- s("echo", { t("fmt.Println("), i(1), t(")"), i(2) })
+ s("echo", { t("fmt.Println("), i(1), t(")"), i(2) }),
+ s("echof", { t("fmt.Printf(\"%v\\n\", "), i(1), t(")"), i(2) }),
+ s("log", { t("fmt.Println("), i(1), t(")"), i(2) }),
+ s("logf", { t("fmt.Printf(\"%v\\n\", "), i(1), t(")"), i(2) }),
})