diff options
| author | Mike Vink <59492084+ivi-vink@users.noreply.github.com> | 2024-12-12 22:41:27 +0000 |
|---|---|---|
| committer | Mike Vink <59492084+ivi-vink@users.noreply.github.com> | 2024-12-12 22:41:27 +0000 |
| commit | aa5794e7e70b63393043a09a49e16a5f1235aae3 (patch) | |
| tree | f17a060cc36ae0f4e3d32cc6a17e77589b99170d /mut/neovim | |
| parent | 33e45ed710d478e01db665d4355e9f4b51ecc3c0 (diff) | |
push again for once
Diffstat (limited to 'mut/neovim')
| -rw-r--r-- | mut/neovim/lua/my/events.lua | 39 | ||||
| -rw-r--r-- | mut/neovim/lua/my/init.lua | 176 | ||||
| -rw-r--r-- | mut/neovim/lua/my/lsp.lua | 47 | ||||
| -rw-r--r-- | mut/neovim/lua/my/packages/luasnip.lua | 5 |
4 files changed, 216 insertions, 51 deletions
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) }), }) |
