From 59bae3ef8781baab01c2af37825681e9366ce824 Mon Sep 17 00:00:00 2001 From: zymon Date: Sun, 8 Sep 2024 18:27:11 +0200 Subject: [PATCH] some plugins --- lua/znvim/plugins/init.lua | 134 ++++++++++++++++++++++++++++++++++++- lua/znvim/plugins/lsp.lua | 2 +- 2 files changed, 134 insertions(+), 2 deletions(-) diff --git a/lua/znvim/plugins/init.lua b/lua/znvim/plugins/init.lua index a564707..2e6a2de 100644 --- a/lua/znvim/plugins/init.lua +++ b/lua/znvim/plugins/init.lua @@ -1 +1,133 @@ -return {} +return { + { -- display undo tree for a file + "https://github.com/mbbill/undotree", + cmd = "UndotreeToggle", + keys = { + { "ut", "UndotreeToggle", desc = "undo tree" }, + }, + }, + { -- markview.nvim + "https://github.com/OXY2DEV/markview.nvim", + ft = 'markdown', + keys = { + { -- toggle markview rendering + "t", + "Markview toggle", + desc = "Toggle markdown rendering", + ft = "markdown" + }, + }, + opts = { + modes = { "n", "i", "no", "c" }, + hybrid_modes = { "i" }, + callbacks = { + on_enable = function (_, win) + vim.wo[win].conceallevel = 2; + vim.wo[win].concealcursor = "nc"; + end + } + }, + }, + { -- repl integration + "https://github.com/Vigemus/iron.nvim", + keys = { + { "rs", "IronRepl", desc = "Show/start REPL" }, + { "rh", "IronHide", desc = "Hide REPL" }, + { "rf", "IronFocus", desc = "Focus REPL" }, + { "rr", "IronRestart", desc = "Restart REPL" }, + { "rq", function() require("iron").core.close_repl(vim.bo.filetype) end, desc = "Quit REPL" }, + }, + opts = { + config = { + -- Whether a repl should be discarded or not + scratch_repl = true, + -- Your repl definitions come here + repl_definition = { + sh = { + -- Can be a table or a function that + -- returns a table (see below) + command = {"zsh"} + }, + julia = { + command = {"julia", "--project", "--threads", "4"}, + }, + }, + repl_open_cmd = "vertical botright 80 split", -- require("iron").view.split.vertical.botright(100), + }, + -- Iron doesn't set keymaps by default anymore. + -- You can set them here or manually add keymaps to the functions in iron.core + keymaps = { + send_motion = "ss", + visual_send = "ss", + send_file = "sf", + send_line = "sl", + send_until_cursor = "su", + -- send_mark = "sm", + mark_motion = "mc", + mark_visual = "mc", + remove_mark = "md", + cr = "s", + interrupt = "s", + clear = "cl", + }, + -- If the highlight is on, you can change how it looks + -- For the available options, check nvim_set_hl + highlight = { + italic = false, + }, + ignore_blank_lines = true, -- ignore blank lines when sending visual select lines + }, + config = function (_, opts) + local iron = require("iron.core") + iron.setup(opts) + + IronSendCell = function(next_cell) + -- source: https://github.com/Vigemus/iron.nvim/issues/236#issuecomment-1317674256 + local iron_core = require('iron.core') + local marks = require('iron.marks') + + local cell_pattern = "^\\s*##" -- cell delimiter pattern + local cell_start = vim.fn.search(cell_pattern, 'bcnW') + local cell_end = vim.fn.search(cell_pattern, 'nW') + + local lines = vim.api.nvim_buf_get_lines(0, cell_start, cell_end-1, 0) + -- ignore blank lines + local b_lines = {} + for _, line in ipairs(lines) do + if line:gsub("^%s*(.-)%s*$", "%1") ~= '' then + table.insert(b_lines, line) + end + end + if #b_lines == 0 then return end + + if cell_start == 0 then + cell_start = 1 -- if first cell, then start from first line + end + if cell_end == 0 then + cell_end = vim.fn.line('$') -- set to last line + end + + marks.set{ from_line=cell_start, from_col=0, to_line=cell_end, to_col=-1 } + marks.winrestview() + + iron_core.send(nil, b_lines) + if next_cell == true then + vim.fn.cursor(cell_end+1, 0) -- move to next cell start + end + end + + vim.keymap.set('n', 'sc', function () IronSendCell(false) end) + vim.keymap.set('n', 'sC', function () IronSendCell(true) end) + vim.cmd("nmap sp ssap") + end + }, + { -- neodev + "https://github.com/folke/lazydev.nvim", + ft = "lua", + }, + { -- A better user experience for interacting with and manipulating marks + "https://github.com/chentoast/marks.nvim", + event = "BufReadPost", + config = true, + }, +} diff --git a/lua/znvim/plugins/lsp.lua b/lua/znvim/plugins/lsp.lua index dc74a3d..d91ba6b 100644 --- a/lua/znvim/plugins/lsp.lua +++ b/lua/znvim/plugins/lsp.lua @@ -157,7 +157,7 @@ return { -- "neocmake", "dockerls", "elixirls", - "fennel_ls", + -- "fennel_ls", "fortls", "html", "biome", -- js + json