From 77035a2af484086db7fd1b27af118dc2e6bbed91 Mon Sep 17 00:00:00 2001 From: davidontop Date: Wed, 9 Apr 2025 20:31:22 +0200 Subject: [PATCH] new --- new/after/init.lua | 31 ++ new/init.lua | 2 + new/lazy-lock.json | 77 ++++ new/lua/config/commands.lua | 163 +++++++ new/lua/config/init.lua | 4 + new/lua/config/keymap.lua | 240 ++++++++++ new/lua/config/packages.lua | 361 +++++++++++++++ new/lua/config/pmstrap.lua | 25 ++ new/lua/config/sets.lua | 57 +++ new/lua/plugins/autopairs.lua | 15 + new/lua/plugins/dap.lua | 44 ++ new/lua/plugins/git.lua | 10 + new/lua/plugins/init.lua | 11 + new/lua/plugins/lsp.lua | 266 ++++++++++++ new/lua/plugins/mini.lua | 10 + new/lua/plugins/neotree.lua | 7 + new/lua/plugins/none-ls.lua | 16 + new/lua/plugins/rust.lua | 141 ++++++ new/lua/plugins/statusline.lua | 773 +++++++++++++++++++++++++++++++++ new/lua/plugins/telescope.lua | 17 + new/lua/plugins/treesitter.lua | 55 +++ 21 files changed, 2325 insertions(+) create mode 100755 new/after/init.lua create mode 100755 new/init.lua create mode 100755 new/lazy-lock.json create mode 100755 new/lua/config/commands.lua create mode 100755 new/lua/config/init.lua create mode 100755 new/lua/config/keymap.lua create mode 100755 new/lua/config/packages.lua create mode 100755 new/lua/config/pmstrap.lua create mode 100755 new/lua/config/sets.lua create mode 100755 new/lua/plugins/autopairs.lua create mode 100755 new/lua/plugins/dap.lua create mode 100755 new/lua/plugins/git.lua create mode 100755 new/lua/plugins/init.lua create mode 100755 new/lua/plugins/lsp.lua create mode 100755 new/lua/plugins/mini.lua create mode 100755 new/lua/plugins/neotree.lua create mode 100755 new/lua/plugins/none-ls.lua create mode 100755 new/lua/plugins/rust.lua create mode 100755 new/lua/plugins/statusline.lua create mode 100755 new/lua/plugins/telescope.lua create mode 100755 new/lua/plugins/treesitter.lua diff --git a/new/after/init.lua b/new/after/init.lua new file mode 100755 index 0000000..4b18edf --- /dev/null +++ b/new/after/init.lua @@ -0,0 +1,31 @@ +vim.opt.nu = true +vim.opt.number = true +vim.opt.relativenumber = true + + +vim.opt.cursorline = true +-- vim.cmd[[ +-- highlight CursorColumn guibg=none ctermbg=none +-- highlight link CursorColumn CursorLine +-- ]] + +-- fixmap +vim.cmd[[ +map m\ +map m/ +map mA +map mgS + +map tt +map tm +]] + +vim.opt.nu = true +vim.opt.number = true +vim.opt.relativenumber = true + + +vim.opt.cursorline = true + + +require("plugins") diff --git a/new/init.lua b/new/init.lua new file mode 100755 index 0000000..a75bc2d --- /dev/null +++ b/new/init.lua @@ -0,0 +1,2 @@ +require("config") +require("plugins") diff --git a/new/lazy-lock.json b/new/lazy-lock.json new file mode 100755 index 0000000..c7353ff --- /dev/null +++ b/new/lazy-lock.json @@ -0,0 +1,77 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, + "Ionide-vim": { "branch": "master", "commit": "c7e8973426431839e9d888a4aa8d6a41251ba16f" }, + "LuaSnip": { "branch": "master", "commit": "33b06d72d220aa56a7ce80a0dd6f06c70cd82b9d" }, + "close-buffers.nvim": { "branch": "master", "commit": "3acbcad1211572342632a6c0151f839e7dead27f" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" }, + "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "crates.nvim": { "branch": "main", "commit": "1dffccc0a95f656ebe00cacb4de282473430c5a1" }, + "editorconfig-vim": { "branch": "master", "commit": "3c2813f2566d9392ff3614248c5db43c3fda9d5f" }, + "fidget.nvim": { "branch": "main", "commit": "9238947645ce17d96f30842e61ba81147185b657" }, + "friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" }, + "gitsigns.nvim": { "branch": "main", "commit": "5f808b5e4fef30bd8aca1b803b4e555da07fc412" }, + "go.nvim": { "branch": "master", "commit": "c6d5ca26377d01c4de1f7bff1cd62c8b43baa6bc" }, + "guihua.lua": { "branch": "master", "commit": "d783191eaa75215beae0c80319fcce5e6b3beeda" }, + "harpoon": { "branch": "harpoon2", "commit": "a84ab829eaf3678b586609888ef52f7779102263" }, + "heirline.nvim": { "branch": "master", "commit": "cc359b628266cb9a84b2d71c883f2b99e16473a0" }, + "hop.nvim": { "branch": "master", "commit": "1a1eceafe54b5081eae4cb91c723abd1d450f34b" }, + "indent-blankline.nvim": { "branch": "master", "commit": "259357fa4097e232730341fa60988087d189193a" }, + "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, + "lsp-inlayhints.nvim": { "branch": "main", "commit": "d981f65c9ae0b6062176f0accb9c151daeda6f16" }, + "lsp-lens.nvim": { "branch": "main", "commit": "48bb1a7e271424c15f3d588d54adc9b7c319d977" }, + "lsp_signature.nvim": { "branch": "master", "commit": "fc38521ea4d9ec8dbd4c2819ba8126cea743943b" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "8e46de9241d3997927af12196bd8faa0ed08c29a" }, + "mason-nvim-dap.nvim": { "branch": "main", "commit": "8b9363d83b5d779813cdd2819b8308651cec2a09" }, + "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, + "melange-nvim": { "branch": "master", "commit": "9252c78c7bffd3126b0c9e47e51e0b5211acffb1" }, + "mini.nvim": { "branch": "main", "commit": "7ebfab26d77a4b9b05aaae565907e7fa4b2ee154" }, + "neo-tree.nvim": { "branch": "v2.x", "commit": "80dc74d081823649809f78370fa5b204aa9a853a" }, + "neodev.nvim": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" }, + "neoscroll.nvim": { "branch": "master", "commit": "f957373912e88579e26fdaea4735450ff2ef5c9c" }, + "none-ls.nvim": { "branch": "main", "commit": "40dc2e983560acaea29d6312b33fafba37b0c272" }, + "nui.nvim": { "branch": "main", "commit": "53e907ffe5eedebdca1cd503b00aa8692068ca46" }, + "numb.nvim": { "branch": "master", "commit": "3f7d4a74bd456e747a1278ea1672b26116e0824d" }, + "nvim-autopairs": { "branch": "master", "commit": "b464658e9b880f463b9f7e6ccddd93fb0013f559" }, + "nvim-bqf": { "branch": "main", "commit": "1b24dc6050c34e8cd377b6b4cd6abe40509e0187" }, + "nvim-cmp": { "branch": "main", "commit": "98e8b9d593a5547c126a39212d6f5e954a2d85dd" }, + "nvim-dap": { "branch": "master", "commit": "567da83810dd9da32f9414d941bc6848715fc102" }, + "nvim-dap-ui": { "branch": "master", "commit": "f7d75cca202b52a60c520ec7b1ec3414d6e77b0f" }, + "nvim-dap-virtual-text": { "branch": "master", "commit": "76d80c3d171224315b61c006502a1e30c213a9ab" }, + "nvim-jdtls": { "branch": "master", "commit": "ece818f909c6414cbad4e1fb240d87e003e10fda" }, + "nvim-lspconfig": { "branch": "master", "commit": "9f2c279cf9abe584f03bfeb37c6658d68e3ff49d" }, + "nvim-metals": { "branch": "main", "commit": "abf4a2b7ccdb2fa21ef59b66e50d9b69a746e3ef" }, + "nvim-navbuddy": { "branch": "master", "commit": "f22bac988f2dd073601d75ba39ea5636ab6e38cb" }, + "nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" }, + "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, + "nvim-surround": { "branch": "main", "commit": "9f0cb495f25bff32c936062d85046fbda0c43517" }, + "nvim-treesitter": { "branch": "master", "commit": "102bc74e093ef54aab57a368db15befeb9ba9d58" }, + "nvim-treesitter-context": { "branch": "master", "commit": "8fd989b6b457a448606b4a2e51f9161700f609a7" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "ad8f0a472148c3e0ae9851e26a722ee4e29b1595" }, + "nvim-ts-autotag": { "branch": "main", "commit": "1cca23c9da708047922d3895a71032bc0449c52d" }, + "nvim-web-devicons": { "branch": "master", "commit": "0eb18da56e2ba6ba24de7130a12bcc4e31ad11cb" }, + "org-bullets.nvim": { "branch": "main", "commit": "46ae687e22192fb806b5977d664ec98af9cf74f6" }, + "orgmode": { "branch": "master", "commit": "db7f04435eae7191cb0ffb0e0cf2a1e9484f4a8b" }, + "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, + "pretty-fold.nvim": { "branch": "master", "commit": "a7d8b424abe0eedf50116c460fbe6dfd5783b1d5" }, + "rainbow_csv.nvim": { "branch": "main", "commit": "7f3fddfe813641035fac2cdf94c2ff69bb0bf0b9" }, + "rustaceanvim": { "branch": "master", "commit": "0a618c1d1c05a8059880076feccb15301da6993d" }, + "suda.vim": { "branch": "master", "commit": "9adda7d195222d4e2854efb2a88005a120296c47" }, + "telescope-dap.nvim": { "branch": "master", "commit": "783366bd6c1e7fa0a5c59c07db37f49c805a28df" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "dae2eac9d91464448b584c7949a31df8faefec56" }, + "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, + "templ.vim": { "branch": "main", "commit": "5cc48b93a4538adca0003c4bc27af844bb16ba24" }, + "todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" }, + "toggleterm.nvim": { "branch": "main", "commit": "022ff5594acccc8d90d2e46dc43994f7722ebdf7" }, + "transparent.nvim": { "branch": "main", "commit": "8a2749a2fa74f97fe6557f61b89ac7fd873f3c21" }, + "undotree": { "branch": "master", "commit": "78b5241191852ffa9bb5da5ff2ee033160798c3b" }, + "vim-glsl": { "branch": "master", "commit": "40dd0b143ef93f3930a8a409f60c1bb85e28b727" }, + "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, + "vim-slint": { "branch": "main", "commit": "9badce3860297562bb5e80ba1666628f9e0ac632" }, + "vim-visual-multi": { "branch": "master", "commit": "a6975e7c1ee157615bbc80fc25e4392f71c344d4" }, + "which-key.nvim": { "branch": "main", "commit": "8ab96b38a2530eacba5be717f52e04601eb59326" }, + "wilder.nvim": { "branch": "master", "commit": "679f348dc90d80ff9ba0e7c470c40a4d038dcecf" }, + "zig.vim": { "branch": "master", "commit": "15d6510b77a4efbb6ffcb151ed7e2ce4de4d06f6" } +} diff --git a/new/lua/config/commands.lua b/new/lua/config/commands.lua new file mode 100755 index 0000000..a6fac63 --- /dev/null +++ b/new/lua/config/commands.lua @@ -0,0 +1,163 @@ +local pickers = require "telescope.pickers" +local finders = require "telescope.finders" +local conf = require("telescope.config").values +local actions = require "telescope.actions" +local action_state = require "telescope.actions.state" + +vim.api.nvim_create_user_command("OP", function () + local folders = vim.fn.systemlist("\\ls -d $HOME/projects/*/") + for i, folder in ipairs(folders) do + folders[i] = string.match(string.match(folder, "[^/]*/$"), "^[^/]*") + end + pickers.new({}, { + prompt_title = "Open project", + finder = finders.new_table { + results = folders + }, + sorter = conf.generic_sorter({}), + attach_mappings = function (prompt_bufnr, map) + actions.select_default:replace(function () + actions.close(prompt_bufnr) + local selection = action_state.get_selected_entry() + selection = selection[1] + vim.cmd("cd $HOME/projects/" .. selection) + end) + return true + end + }):find() +end, {}) + +vim.api.nvim_create_user_command("OD", function () + local folders = vim.fn.systemlist("\\ls -d */") + for i, folder in ipairs(folders) do + folders[i] = string.match(string.match(folder, "[^/]*/$"), "^[^/]*") + end + pickers.new({}, { + prompt_title = "Open directory", + finder = finders.new_table { + results = folders + }, + sorter = conf.generic_sorter({}), + attach_mappings = function (prompt_bufnr, map) + actions.select_default:replace(function () + actions.close(prompt_bufnr) + local selection = action_state.get_selected_entry() + selection = selection[1] + vim.cmd("cd " .. selection) + end) + return true + end + }):find() +end, {}) + +vim.api.nvim_create_user_command("Config", function () + vim.cmd("cd $HOME/.config/nvim") +end, {}) + +vim.api.nvim_create_user_command("RetabFile2Spaces", function () + vim.cmd(":set ts=2 sts=2 noet | retab! | set ts=4 sts=4 et | retab!") +end, {}) +vim.api.nvim_create_user_command("RetabFile4SpacesToTab", function () + vim.cmd(":set ts=4 sts=4 noet | retab! | set ts=4 sts=0 noexpandtab | retab!") +end, {}) + +local function get_makefile_targets() + local makefile = "./Makefile" + local targets = {} + + local file = io.open(makefile, "r") + if file then + for line in file:lines() do + local target = line:match("^[^\\s:]+:.*") + if target then + local tg = target:match("^[^:]+") + table.insert(targets, tg) + end + end + file:close() + end + return targets +end + +vim.api.nvim_create_user_command("Make", function (args) + local vimCmd = "TermExec cmd=\"make" + if (args["args"]) then + vimCmd = vimCmd .. " " .. args["args"] + end + vimCmd = vimCmd .. "\"" + vim.cmd(vimCmd) +end, {nargs = "*", ["complete"] = function() + return get_makefile_targets() +end}) + +vim.api.nvim_create_user_command("Maket", function() + local targets = get_makefile_targets() + pickers.new({}, { + prompt_title = "Run make target", + finder = finders.new_table { + results = targets + }, + sorter = conf.generic_sorter({}), + attach_mappings = function (prompt_bufnr, map) + actions.select_default:replace(function () + actions.close(prompt_bufnr) + local selection = action_state.get_selected_entry() + selection = selection[1] + vim.cmd(":Make " .. selection) + end) + return true + end + }):find() +end, {}) + +function get_just_targets() + local handle = io.popen("just --summary") + local res = handle:read("*a") + handle:close() + local targets = {} + -- insert space seperated targets + for target in string.gmatch(res, "%S+") do + table.insert(targets, target) + end +end + +vim.api.nvim_create_user_command("Just", function(args) + local vimCmd = "TermExec cmd=\"just" + if (args["args"]) then + vimCmd = vimCmd .. " " .. args["args"] + end + vimCmd = vimCmd .. "\"" + vim.cmd(vimCmd) +end, {nargs = "*", ["complete"] = function () + return get_just_targets() +end}) + +vim.api.nvim_create_user_command("Justt", function() + local targets = get_makefile_targets() + pickers.new({}, { + prompt_title = "Run just target", + finder = finders.new_table { + results = targets + }, + sorter = conf.generic_sorter({}), + attach_mappings = function (prompt_bufnr, map) + actions.select_default:replace(function () + actions.close(prompt_bufnr) + local selection = action_state.get_selected_entry() + selection = selection[1] + vim.cmd(":Just " .. selection) + end) + return true + end + }):find() +end, {}) + + +vim.api.nvim_create_autocmd('TextYankPost', { + desc = 'Highlight when yanking (copying) text', + group = vim.api.nvim_create_augroup('HightlightYank', { clear = true }), + callback = function() + vim.highlight.on_yank() + end, +}) + diff --git a/new/lua/config/init.lua b/new/lua/config/init.lua new file mode 100755 index 0000000..4c4eafe --- /dev/null +++ b/new/lua/config/init.lua @@ -0,0 +1,4 @@ +require("config.pmstrap") +require("config.sets") +require("config.keymap") +require("config.commands") diff --git a/new/lua/config/keymap.lua b/new/lua/config/keymap.lua new file mode 100755 index 0000000..68d333a --- /dev/null +++ b/new/lua/config/keymap.lua @@ -0,0 +1,240 @@ +-- local wk = require("which-key") +-- +-- local keys = { +-- e = { +-- name = "Toggle", +-- e = {"NeoTreeFloatToggle", "NeoTree"}, +-- w = {vim.cmd.Ex, "netrw"}, +-- s = {"NeoTreeShowToggle", "neotree sidebar"}, +-- g = {"NeoTreeFloatToggle git_status", "Git Status"}, +-- -- b = {"NeoTreeFloatToggle buffers", "Buffers"}, +-- c = {"NeoTreeClose" , "Close"}, +-- u = {vim.cmd.UndotreeToggle, "UndoTree"}, +-- }, +-- c = { +-- name = "LSP", +-- f = {function () vim.lsp.buf.format() end, "Format"}, +-- w = {function () vim.lsp.buf.workspace_symbol("") end, "workspace symbol"}, +-- d = {function () vim.diagnostic.open_float() end, "diagnostic"}, +-- a = {function () vim.lsp.buf.code_action() end, "code actions"}, +-- R = {function () vim.lsp.buf.references() end, "references"}, +-- r = {function () vim.lsp.buf.rename() end, "rename"}, +-- h = {function () vim.lsp.buf.hover() end, "Hover"}, +-- t = {function () vim.lsp.buf.type_definition() end,"Type Definition"}, +-- s = {"Navbuddy", "Navbuddy"}, +-- S = {require("telescope.builtin").lsp_document_symbols, "Document Symbols"}, +-- l = { +-- name = "LSP", +-- k = {"LspStop", "Stop"}, +-- s = {"LspStart", "Start"}, +-- r = {"LspRestart", "Restart"}, +-- }, +-- }, +-- b = { +-- name = "Buffer", +-- h = {vim.cmd.bprevious, "Previous"}, +-- l = {vim.cmd.bnext, "Next"}, +-- H = {vim.cmd.bfirst, "First"}, +-- L = {vim.cmd.blast, "Last"}, +-- b = {require("telescope.builtin").buffers, "Picker"}, +-- c = {":bp | sp | bn | bd", "Close"}, +-- C = {":bp | sp | bn | bd!", "Close Force"}, +-- d = {function() vim.cmd("bd") end, "Delete buffer"}, +-- D = {function() vim.cmd("bd!") end, "Delete buffer Force"}, +-- o = {function() vim.cmd("BDelete other") end, "Delete other buffers"}, +-- m = {function() vim.cmd("BDelete select") end, "Select buffer to delete"}, +-- }, +-- f = { +-- name = "Telescope & fzf", +-- c = {require("telescope.builtin").colorscheme, "Find Colorscheme"}, +-- d = {require("telescope.builtin").diagnostics, "Find Diagnostics"}, +-- w = {require("telescope.builtin").grep_string, "Find current Word"}, +-- f = {require("telescope.builtin").find_files, "telescope find files"}, +-- g = {require("telescope.builtin").live_grep, "live grep"}, +-- b = {require("telescope.builtin").buffers, "buffers"}, +-- h = {require("telescope.builtin").help_tags, "help tags"}, +-- s = {function () require("telescope.builtin").grep_string({ search = vim.fn.input("Grep > ")}); end, "grep search through files"}, +-- m = {"Maket", "Make"}, +-- }, +-- s = { +-- name = "Settings", +-- c = {function () +-- vim.opt.scrolloff = 100 +-- end, "Always center cursor"}, +-- C = {function () +-- vim.opt.scrolloff = 8 +-- end, "Disable Cursor center"}, +-- f = {function () +-- vim.opt.nu = true +-- vim.opt.relativenumber = true +-- end, "Fix number and relative numbers"}, +-- }, +-- h = { +-- name = "Hop", +-- w = {"HopWord", "Word"}, +-- a = {"HopAnywhere", "Anywhere"}, +-- l = {"HopLine", "Line"}, +-- p = {"HopPattern", "Pattern"}, +-- c = {"HopChar1", "Char1"}, +-- x = {"HopChar2", "Char2"}, +-- h = {vim.cmd.HopChar2, "Hop"}, +-- }, +-- d = { +-- name = "Debug", +-- b = {function () require("dap").toggle_breakpoint() end, "toggle breakpoint"}, +-- c = {function () require("dap").continue() end, "launch or continue execution"}, +-- s = {function () require("dap").step_into() end, "step into"}, +-- o = {function () require("dap").step_over() end, "step over"}, +-- r = {function () require("dap").repl.open() end, "open repl"}, +-- w = {"DapUIFloat", "DapUI"}, +-- }, +-- w = { +-- name = "workspace", +-- a = {vim.lsp.buf.add_workspace_folder, "add folder"}, +-- r = {vim.lsp.buf.remove_workspace_folder, "remove folder"}, +-- l = {function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end, "list folders"}, +-- }, +-- q = { +-- name = "Quick nav", +-- q = {require("harpoon.ui").toggle_quick_menu, "Menu"}, +-- a = {function () require("harpoon"):list():append() end, "Add file"}, +-- r = {function () require("harpoon"):list():remove() end, "Remove File"}, +-- }, +-- +-- } +-- +-- wk.register(keys, {prefix = ""}) +-- wk.register(keys, {prefix = ""}) +-- wk.register(keys, {prefix = "", mode = "i"}) +-- wk.register(keys, {prefix = "", mode = "v"}) + +local keys = { + { "bC", ":bp | sp | bn | bd!", desc = "Close Force" }, + { "bD", function() vim.cmd("bd!") end, desc = "Delete buffer Force" }, + { "bH", vim.cmd.bfirst, desc = "First" }, + { "bL", vim.cmd.blast, desc = "Last" }, + { "bb", require("telescope.builtin").buffers, desc = "Picker" }, + { "bc", ":bp | sp | bn | bd", desc = "Close" }, + { "bd", vim.cmd.bd, desc = "Delete buffer" }, + { "bh", vim.cmd.bprevious, desc = "Previous" }, + { "bl", vim.cmd.bnext, desc = "Next" }, + { "bm", function() vim.cmd("BDelete select") end, desc = "Select buffer to delete" }, + { "bo", function() vim.cmd("BDelete other") end, desc = "Delete other buffers" }, + + { "cR", vim.lsp.buf.references, desc = "references" }, + { "cS", require("telescope.builtin").lsp_document_symbols, desc = "Document Symbols" }, + { "ca", vim.lsp.buf.code_action, desc = "code actions" }, + { "cd", vim.diagnostic.open_float, desc = "diagnostic" }, + { "cf", vim.lsp.buf.format, desc = "Format" }, + { "ch", vim.lsp.buf.hover, desc = "Hover" }, + + { "clk", "LspStop", desc = "Stop" }, + { "clr", "LspRestart", desc = "Restart" }, + { "cls", "LspStart", desc = "Start" }, + { "cr", vim.lsp.buf.rename, desc = "rename" }, + { "cs", "Navbuddy", desc = "Navbuddy" }, + { "ct", vim.lsp.buf.type_definition, desc = "Type Definition" }, + { "cw", function() vim.lsp.buf.workspace_symbol("") end, desc = "workspace symbol" }, + + { "db", require("dap").toggle_breakpoint, desc = "toggle breakpoint" }, + { "dc", require("dap").continue, desc = "launch or continue execution" }, + { "do", require("dap").step_over, desc = "step over" }, + { "dr", require("dap").repl.open, desc = "open repl" }, + { "ds", require("dap").step_into, desc = "step into" }, + { "dw", "DapUIFloat", desc = "DapUI" }, + + { "ec", "NeoTreeClose", desc = "Close" }, + { "ee", "NeoTreeFloatToggle", desc = "NeoTree" }, + { "eg", "NeoTreeFloatToggle git_status", desc = "Git Status" }, + { "es", "NeoTreeShowToggle", desc = "neotree sidebar" }, + { "eu", vim.cmd.UndotreeToggle, desc = "UndoTree" }, + { "ew", vim.cmd.Ex, desc = "netrw" }, + + { "fb", require("telescope.builtin").buffers, desc = "buffers" }, + { "fc", require("telescope.builtin").colorscheme, desc = "Find Colorscheme" }, + { "fd", require("telescope.builtin").diagnostics, desc = "Find Diagnostics" }, + { "ff", require("telescope.builtin").find_files, desc = "telescope find files" }, + { "fg", require("telescope.builtin").live_grep, desc = "live grep" }, + { "fh", require("telescope.builtin").help_tags, desc = "help tags" }, + { "fm", "Maket", desc = "Make"}, + { "fs", function () require("telescope.builtin").grep_string({ search = vim.fn.input("Grep > ")}); end, desc = "grep search through files" }, + { "fw", require("telescope.builtin").grep_string, desc = "Find current Word" }, + + { "ha", "HopAnywhere", desc = "Anywhere" }, + { "hc", "HopChar1", desc = "Char1" }, + { "hh", vim.cmd.HopChar2, desc = "Hop" }, + { "hl", "HopLine", desc = "Line" }, + { "hp", "HopPattern", desc = "Pattern" }, + { "hw", "HopWord", desc = "Word" }, + { "hx", "HopChar2", desc = "Char2" }, + + { "qa", function () require("harpoon"):list():append() end, desc = "Add file" }, + { "qq", require("harpoon.ui").toggle_quick_menu, desc = "Menu" }, + { "qr", function() require("harpoon"):list():remove() end, desc = "Remove File" }, + + { "sC", function() vim.opt.scrolloff = 8 end, desc = "Disable Cursor center" }, + { "sc", function() vim.opt.scrolloff = 100 end, desc = "Always center cursor" }, + { "sf", function() vim.opt.nu = true; vim.opt.relativenumber = true end, desc = "Fix number and relative numbers" }, + + { "wa", vim.lsp.buf.add_workspace_folder, desc = "add folder" }, + { "wl", function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end, desc = "list folders" }, + { "wr", vim.lsp.buf.remove_workspace_folder, desc = "remove folder" }, +} + +for i, key in ipairs(keys) do + vim.keymap.set("n", "" .. key[1], key[2], {desc = key["desc"]}) + vim.keymap.set("n", "" .. key[1], key[2], {desc = key["desc"]}) + vim.keymap.set("i", "" .. key[1], key[2], {desc = key["desc"]}) + vim.keymap.set("v", "" .. key[1], key[2], {desc = key["desc"]}) +end + +-- LSP +vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, {desc = "goto definition"}) +vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, {}) +vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, {desc = "goto next"}) +vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, {desc = "goto prev"}) +vim.keymap.set("i", "", function() vim.lsp.buf.signature_help() end) +vim.keymap.set("i", "", function () vim.lsp.buf.hover() end, {}) + +-- term +vim.keymap.set("n", "", vim.cmd.ToggleTerm) +vim.keymap.set("t", "", vim.cmd.ToggleTerm) +vim.keymap.set("v", "", vim.cmd.ToggleTerm) + +-- center +vim.keymap.set("n", "", "zz") +vim.keymap.set("n", "", "zz") +vim.keymap.set("n", "n", "nzzzv") +vim.keymap.set("n", "N", "Nzzzv") + +-- visual move +vim.keymap.set("x", "K", ":move '<-2gv=gv") +vim.keymap.set("x", "J", ":move '>+1gv=gv") + +-- me lazy +vim.keymap.set("i", "", "") + + +-- non char keybinds +vim.keymap.set("n", "f/", function () + require("telescope.builtin").current_buffer_fuzzy_find(require("telescope.themes").get_dropdown { + winblend = 10, + previewer = false, + }) +end, {desc = "fuzzy find"}) +vim.keymap.set('n', 'f?', require('telescope.builtin').oldfiles, { desc = 'Find recently opened files' }) + +vim.keymap.set("i", "f/", function () + require("telescope.builtin").current_buffer_fuzzy_find(require("telescope.themes").get_dropdown { + winblend = 10, + previewer = false, + }) +end, {desc = "fuzzy find"}) +vim.keymap.set('i', 'f?', require('telescope.builtin').oldfiles, { desc = 'Find recently opened files' }) + +for i = 9, 1, -1 do + vim.keymap.set("n", "", function() require("harpoon"):list():select(i) end, {desc = ""}) + vim.keymap.set("i", "", function() require("harpoon"):list():select(i) end, {desc = ""}) + vim.keymap.set("v", "", function() require("harpoon"):list():select(i) end, {desc = ""}) +end + diff --git a/new/lua/config/packages.lua b/new/lua/config/packages.lua new file mode 100755 index 0000000..285bda0 --- /dev/null +++ b/new/lua/config/packages.lua @@ -0,0 +1,361 @@ +return { + { + "neovim/nvim-lspconfig", + dependencies = { + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + "j-hui/fidget.nvim", + "folke/neodev.nvim", + }, + }, + { + "VidocqH/lsp-lens.nvim", + opts = {}, + }, + { + "j-hui/fidget.nvim", + dependencies = { + "neovim/nvim-lspconfig", + }, + }, + { + "SmiteshP/nvim-navic", + dependencies = {"neovim/nvim-lspconfig"}, + opts = {highlight = true}, + }, + { + "ray-x/lsp_signature.nvim", + event = "BufRead", + config = function() require"lsp_signature".on_attach() end, + }, + { + "hrsh7th/nvim-cmp", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "L3MON4D3/LuaSnip", + "saadparwaiz1/cmp_luasnip", + "hrsh7th/cmp-nvim-lua", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "rafamadriz/friendly-snippets" + }, + }, + { + "nvimtools/none-ls.nvim" + }, + + -- syntax highlighting + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate" + }, + 'nvim-treesitter/nvim-treesitter-context', + { + "nvim-treesitter/nvim-treesitter-textobjects", + dependencies = {"nvim-treesitter"}, + }, + + -- fzf Telescope + { + "nvim-telescope/telescope.nvim", + branch = "0.1.x", + dependencies = { + "nvim-lua/plenary.nvim" + } + }, + { + "nvim-telescope/telescope-fzf-native.nvim", + build = "make", + }, + + -- debugging + "mfussenegger/nvim-dap", + "jay-babu/mason-nvim-dap.nvim", + { + "rcarriga/nvim-dap-ui", + tag = "v4.0.0", + dependencies = { + "mfussenegger/nvim-dap", + "nvim-neotest/nvim-nio" + }, + }, + {"theHamsta/nvim-dap-virtual-text", opts = {}}, + "nvim-telescope/telescope-dap.nvim", + + -- git + "lewis6991/gitsigns.nvim", + + "lvimuser/lsp-inlayhints.nvim", + "echasnovski/mini.nvim", + {'kazhala/close-buffers.nvim', config = true}, + { + 'anuvyklack/pretty-fold.nvim', + opts = { + keep_indentation = true, + fill_char = '━', + sections = { + left = { + '━ ', function() return string.rep('*', vim.v.foldlevel) end, ' ━┫', 'content', '┣' + }, + right = { + '┫ ', 'number_of_folded_lines', ': ', 'percentage', ' ┣━━', + } + } + } + }, + "editorconfig/editorconfig-vim", + {"nacro90/numb.nvim", opts = {}}, + {"kylechui/nvim-surround", opts={}}, + { + "phaazon/hop.nvim", + event = "BufRead", + opts = {} + }, + { + "ThePrimeagen/harpoon", + branch = "harpoon2", + dependencies = { "nvim-lua/plenary.nvim" }, + init = function () + local harpoon = require("harpoon") + harpoon:setup() + end + }, + + -- misc editing + "lambdalisue/suda.vim", + "tpope/vim-sleuth", + "mbbill/undotree", + {"windwp/nvim-autopairs", opts = {}}, + { + "mg979/vim-visual-multi", + config = function () + vim.cmd([[ + let g:VM_leader='m' + let g:VM_maps['Find Under'] = '' + ]]) + end + }, + + { + "windwp/nvim-ts-autotag", + opts = { + filetypes = {'html', 'javascript', 'typescript', 'javascriptreact', 'typescriptreact', 'svelte', 'vue', 'tsx', 'jsx', 'rescript', 'xml', 'php', 'markdown', 'astro', 'glimmer', 'handlebars', 'hbs', "rust" }, + }, + }, + { + "kevinhwang91/nvim-bqf", + event = { "BufRead", "BufNew" }, + opts = { + auto_enable = true, + preview = { + win_height = 12, + win_vheight = 12, + delay_syntax = 80, + border_chars = { "┃", "┃", "━", "━", "┏", "┓", "┗", "┛", "█" }, + }, + func_map = { + vsplit = "", + ptogglemode = "z,", + stoggleup = "", + }, + filter = { + fzf = { + action_for = { ["ctrl-s"] = "split" }, + extra_opts = { "--bind", "ctrl-o:toggle-all", "--prompt", "> " }, + }, + }, + } + }, + "nvim-tree/nvim-web-devicons", + { + "lukas-reineke/indent-blankline.nvim", + init = function () + require("ibl").setup({ + indent = { + tab_char = "│", + char = "┊", + }, + }) + end + }, + { + "folke/which-key.nvim", + config = function() + local wk = require("which-key") + wk.setup { + -- popup_mappings = { + -- scroll_down = "", + -- scroll_up = "", + -- }, + -- window = { + -- border = "single", + -- }, + } + end + }, + "rebelot/heirline.nvim", + { + "akinsho/toggleterm.nvim", + version = "*", + opts = { + direction = "float", + float_opts = { + border = "curved" + }, + } + }, + { + "karb94/neoscroll.nvim", + event = "WinScrolled", + opts = { + mappings = {"", "", "", "", "", "", "zt", "zz", "zb"}, + hide_cursor = true, + stop_eof = true, + use_local_scrolloff = false, + respect_scrolloff = false, + cursor_scrolls_alone = true, + easing_function = nil, + pre_hook = nil, + post_hook = nil, + } + }, + { + "folke/todo-comments.nvim", + event = "BufRead", + }, + {'numToStr/Comment.nvim', opts = {}}, + { + "SmiteshP/nvim-navbuddy", + dependencies = { + "neovim/nvim-lspconfig", + "SmiteshP/nvim-navic", + "MunifTanjim/nui.nvim", + "numToStr/Comment.nvim", + "nvim-telescope/telescope.nvim" + }, + opts = { + window = {border="rounded",}, + } + }, + { + "gelguy/wilder.nvim", + config = function() + -- local wilder = require("wilder") + -- wilder.setup({ + -- modes = {":", "/", "?"}, + -- }) + -- wilder.set_option("renderer", wilder.popupmenu_renderer({ + -- pumblend = 50, + -- })) + vim.cmd('call wilder#setup({"modes": [":", "/", "?"]})') + vim.cmd('call wilder#set_option("renderer", wilder#popupmenu_renderer({"highlighter": wilder#basic_highlighter(), "left": [ " ", wilder#popupmenu_devicons(), ], "right": [ " ", wilder#popupmenu_scrollbar(), ], "pumblend": 20}))') + vim.cmd('call wilder#set_option("renderer", wilder#popupmenu_renderer(wilder#popupmenu_border_theme({"highlighter": wilder#basic_highlighter(), "min_width": "100%", "min_height": "50%", "reverse": 0, "highlights": {"border": "Normal",},"border": "rounded"})))') + end, + }, + { + "nvim-neo-tree/neo-tree.nvim", + branch = "v2.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "MunifTanjim/nui.nvim", + }, + }, + + -- lenguage specific + -- the best language in the world (scala) + { + "scalameta/nvim-metals", + dependencies = { + "nvim-lua/plenary.nvim", + }, + ft = { "scala", "sbt", "java" }, + opts = function() + local metals_config = require("metals").bare_config() + metals_config.on_attach = function(client, bufnr) + -- your on_attach function + end + + return metals_config + end, + config = function(self, metals_config) + local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true }) + vim.api.nvim_create_autocmd("FileType", { + pattern = self.ft, + callback = function() + require("metals").initialize_or_attach(metals_config) + end, + group = nvim_metals_group, + }) + end + }, + + -- org + { + "nvim-orgmode/orgmode", + lazy = false, + dependencies = { + "nvim-treesitter/nvim-treesitter", + "hrsh7th/nvim-cmp", + }, + config = function() + require("orgmode").setup({}) + require('nvim-treesitter.configs').setup({ + ensure_installed = 'all', + ignore_install = { 'org' }, + }) + end + }, + { + "akinsho/org-bullets.nvim" + }, + -- f# + {"ionide/Ionide-vim"}, + -- go + {"joerdav/templ.vim"}, + { + "ray-x/go.nvim", + dependencies = { -- optional packages + "ray-x/guihua.lua", + "neovim/nvim-lspconfig", + "nvim-treesitter/nvim-treesitter", + }, + config = function() + require("go").setup() + end, + event = {"CmdlineEnter"}, + ft = {"go", 'gomod'}, + build = ':lua require("go.install").update_all_sync()' -- if you need to install/update all binaries + }, + -- csv + 'cameron-wags/rainbow_csv.nvim', + + -- rust + { + "saecki/crates.nvim", + tag = "v0.3.0", + dependencies = { + "nvim-lua/plenary.nvim" + }, + }, + { + 'mrcjkb/rustaceanvim', + version = '^5', -- Recommended + lazy = false, -- This plugin is already lazy + }, + -- slint + {"slint-ui/vim-slint"}, + + -- zig + "ziglang/zig.vim", + + -- glsl + "tikhomirov/vim-glsl", + + -- java + "mfussenegger/nvim-jdtls", + + -- themes + "xiyaowong/transparent.nvim", + "savq/melange-nvim", +} diff --git a/new/lua/config/pmstrap.lua b/new/lua/config/pmstrap.lua new file mode 100755 index 0000000..725a56e --- /dev/null +++ b/new/lua/config/pmstrap.lua @@ -0,0 +1,25 @@ +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" + +if not (vim.uv or vim.loop).fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "--branch=stable", + "https://github.com/folke/lazy.nvim.git", + lazypath + }) +end +vim.opt.rtp:prepend(lazypath) + + +-- Setup lazy.nvim +require("lazy").setup("config.packages", { + defaults = { + lazy = false, + }, + --install = { colorscheme = { "melange" } }, +}) diff --git a/new/lua/config/sets.lua b/new/lua/config/sets.lua new file mode 100755 index 0000000..73a7666 --- /dev/null +++ b/new/lua/config/sets.lua @@ -0,0 +1,57 @@ +-- numbers +vim.opt.number = true +vim.opt.relativenumber = true + +-- tab && indent +vim.opt.tabstop = 4 +vim.opt.softtabstop = 0 +vim.opt.shiftwidth = 4 +vim.opt.smartindent = true +vim.o.breakindent = true + +-- lines +vim.opt.wrap = true +vim.opt.smarttab = true + +vim.opt.list = true +vim.opt.listchars:append "eol:↴" + +-- undo +vim.opt.undodir = os.getenv("HOME") .. "/.local/share/nvim/undofile" +vim.opt.undofile = true + +-- search +vim.opt.hlsearch = false +vim.opt.incsearch = true + +vim.o.ignorecase = true +vim.o.smartcase = true + +-- colors +vim.opt.termguicolors = true +vim.cmd.colorscheme "melange" + +vim.opt.cursorline = true + +-- misc +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.scrolloff = 8 +vim.opt.sidescrolloff = 8 +vim.opt.signcolumn = "yes" +vim.opt.isfname:append("@-@") +vim.opt.updatetime = 50 +vim.opt.timeoutlen = 300 +vim.o.mouse = "a" +vim.opt.showmode = false + +vim.g.have_nerd_font = true + +vim.o.completeopt = "menuone,noselect" + +-- vim.filetype.add({extension = {leaf = 'html'}}) + + +vim.wo.foldmethod = "manual" +vim.opt.foldcolumn = "1" + diff --git a/new/lua/plugins/autopairs.lua b/new/lua/plugins/autopairs.lua new file mode 100755 index 0000000..885da18 --- /dev/null +++ b/new/lua/plugins/autopairs.lua @@ -0,0 +1,15 @@ +local npairs = require("nvim-autopairs") +local Rule = require("nvim-autopairs.rule") + +npairs.setup({ + check_ts = true, + ts_config = { + lua = {"string"}, + javascript = {"template_string"}, + }, + enable_check_bracket_line = false, + ignored_next_char = "[%w%.]", + +}) + +local ts_conds = require("nvim-autopairs.ts-conds") diff --git a/new/lua/plugins/dap.lua b/new/lua/plugins/dap.lua new file mode 100755 index 0000000..c15d174 --- /dev/null +++ b/new/lua/plugins/dap.lua @@ -0,0 +1,44 @@ +local dap = require("dap") +local dapui = require("dapui") + +dapui.setup() + +local sign = vim.fn.sign_define + +sign("DapBreakpoint", { text = "●", texthl = "DapBreakpoint", linehl = "", numhl = ""}) +sign("DapBreakpointCondition", { text = "●", texthl = "DapBreakpointCondition", linehl = "", numhl = ""}) +sign("DapLogPoint", { text = "◆", texthl = "DapLogPoint", linehl = "", numhl = ""}) + +dap.listeners.after.event_initialized["dapui_config"] = function() + dapui.open() +end +dap.listeners.before.event_terminated["dapui_config"] = function() + dapui.close() +end +dap.listeners.before.event_exited["dapui_config"] = function() + dapui.close() +end + +vim.api.nvim_create_user_command("DapUIFloat", function (at) + dapui.float_element(at.args) +end, {}) + +dap.configurations.scala = { + { + type = "scala", + request = "launch", + name = "RunOrTest", + metals = { + runType = "runOrTestFile", + --args = { "firstArg", "secondArg", "thirdArg" }, -- here just as an example + }, + }, + { + type = "scala", + request = "launch", + name = "Test Target", + metals = { + runType = "testTarget", + }, + }, +} diff --git a/new/lua/plugins/git.lua b/new/lua/plugins/git.lua new file mode 100755 index 0000000..52e6f27 --- /dev/null +++ b/new/lua/plugins/git.lua @@ -0,0 +1,10 @@ +require('gitsigns').setup { + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + }, +} + diff --git a/new/lua/plugins/init.lua b/new/lua/plugins/init.lua new file mode 100755 index 0000000..e98bb6b --- /dev/null +++ b/new/lua/plugins/init.lua @@ -0,0 +1,11 @@ +require("plugins.autopairs") +require("plugins.dap") +require("plugins.git") +require("plugins.lsp") +require("plugins.mini") +require("plugins.neotree") +require("plugins.none-ls") +require("plugins.rust") +require("plugins.statusline") +require("plugins.telescope") +require("plugins.treesitter") diff --git a/new/lua/plugins/lsp.lua b/new/lua/plugins/lsp.lua new file mode 100755 index 0000000..0d0c182 --- /dev/null +++ b/new/lua/plugins/lsp.lua @@ -0,0 +1,266 @@ +-- local ih = require("inlay-hints") + +require('neodev').setup() +-- vim.lsp.ensure_installed({ +-- "clangd", +-- "gopls", +-- "jdtls", +-- "eslint", +-- "tailwindcss", +-- "tsserver", +-- "cssmodules_ls", +-- "rome", +-- "jsonls", +-- "sumneko_lua", +-- "pylsp", +-- "rust_analyzer", +-- "stylelint_lsp", +-- }) + +local navic = require("nvim-navic") +navic.setup { + icons = { + File = " ", + Module = " ", + Namespace = " ", + Package = " ", + Class = " ", + Method = " ", + Property = " ", + Field = " ", + Constructor = " ", + Enum = "練", + Interface = "練", + Function = " ", + Variable = " ", + Constant = " ", + String = " ", + Number = " ", + Boolean = "◩ ", + Array = " ", + Object = " ", + Key = " ", + Null = "ﳠ ", + EnumMember = " ", + Struct = " ", + Event = " ", + Operator = " ", + TypeParameter = " ", + }, + highlight = false, + separator = " > ", + depth_limit = 0, + depth_limit_indicator = "..", + safe_output = true +} + +local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) + +local on_attach = function(client, bufnr) + local nmap = function(keys, func, desc) + if desc then + desc = 'LSP: ' .. desc + end + + vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) + end + + -- ih.on_attach(client, bufnr) + require("lsp-inlayhints").on_attach(client, bufnr) + + if client.server_capabilities.documentSymbolProvider then + navic.attach(client, bufnr) + require("nvim-navbuddy").attach(client, bufnr) + end + + nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') + nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation') + + nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') + + -- Lesser used LSP functionality + nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + + -- Create a command `:Format` local to the LSP buffer + vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) + vim.lsp.buf.format() + end, { desc = 'Format current buffer with LSP' }) + + -- format on save autocmd + if client.supports_method("textDocument/formatting") then + vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + -- on 0.8, you should use vim.lsp.buf.format({ bufnr = bufnr }) instead + -- on later neovim version, you should use vim.lsp.buf.format({ async = false }) instead + -- vim.lsp.buf.formatting_sync() + --vim.lsp.buf.format({async = false, bufnr = bufnr, filter = function(client) return client.name == "null-ls" end}) + vim.lsp.buf.format({async = false, bufnr = bufnr}) + end, + }) + end +end + +local servers = { + -- sumneko_lua = { + -- Lua = { + -- workspace = { checkThirdParty = false }, + -- telemetry = { enable = false }, + -- }, + -- }, +} + +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) +capabilities.offsetEncoding = { "utf-16" } -- fix copilot + +require('mason').setup() +require("mason-nvim-dap").setup({automatic_installation = true, handlers = { + function (config) + require("mason-nvim-dap").default_setup(config) + end +}}) +local mason_lspconfig = require 'mason-lspconfig' +mason_lspconfig.setup { + ensure_installed = vim.tbl_keys(servers), +} +mason_lspconfig.setup_handlers { + function(server_name) + require('lspconfig')[server_name].setup { + capabilities = capabilities, + on_attach = on_attach, + settings = servers[server_name], + } + end, +} + +-- require("lspconfig").rust_analyzer.setup{ +-- capabilities = capabilities, +-- on_attach = on_attach, +-- settings = { +-- -- ["rust-analyzer"] = { +-- cargo = { +-- features = "all" +-- }, +-- inlayHints = { +-- closyreCaptureHints = { +-- enable = true, +-- }, +-- }, +-- check = { +-- command = "clippy", +-- features = "all", +-- }, +-- imports = { +-- preferPrelude = true, +-- } +-- -- }, +-- }, +-- } + +require("lspconfig").zls.setup{ + cmd = {"zls"}, + on_attach = on_attach, +} + +require("lspconfig").tailwindcss.setup { + filetypes = { + "astro", "astro-markdown", "clojure", "django-html", "htmldjango", "edge", "eelixir", "elixir", "ejs", "erb", "eruby", "gohtml", "haml", "handlebars", "hbs", "html", "html-eex", "heex", "jade", "leaf", "liquid", "markdown", "mdx", "mustache", "njk", "nunjucks", "php", "razor", "slim", "twig", "css", "less", "postcss", "sass", "scss", "stylus", "sugarss", "javascript", "javascriptreact", "reason", "rescript", "typescript", "typescriptreact", "vue", "svelte", + "rust", "fsharp", + }, + init_options = { + userLanguages = { + rust = "html", + fsharp = "html", + }, + }, + root_dir = require("lspconfig").util.root_pattern("tailwind.config.cjs", "tailwind.config.mjs", "tailwind.config.js", "tailwind.config.ts"), + settings = { + tailwindCSS = { + --files = {exclude = ""}, + classAttributes = { "class", "className", "class:list", "classList", "ngClass", "classes" }, + lint = { + cssConflict = "warning", + invalidApply = "error", + invalidConfigPath = "error", + invalidScreen = "error", + invalidTailwindDirective = "error", + invalidVariant = "error", + recommendedVariantOrder = "warning" + }, + validate = true + } + } +} + +require("lspconfig").gleam.setup({}) + +-- lspinfo +require('fidget').setup() + +local cmp_autopairs = require('nvim-autopairs.completion.cmp') + +local cmp = require 'cmp' +-- local luasnip = require 'luasnip' + + + +cmp.setup { + -- snippet = { + -- expand = function(args) + -- luasnip.lsp_expand(args.body) + -- end, + -- }, + mapping = cmp.mapping.preset.insert { + -- [""] = cmp.mapping.confirm({ slelect = true}), + [""] = cmp.mapping.complete({}), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + -- elseif luasnip.expand_or_jumpable() then + -- luasnip.expand_or_jump() + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + -- elseif luasnip.jumpable(-1) then + -- luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), + }, + sources = { + { name = 'nvim_lsp' }, + -- { name = 'luasnip' }, + { name = "crates" }, + { name = 'orgmode' }, + }, +} + +cmp.event:on( + 'confirm_done', + cmp_autopairs.on_confirm_done() +) + +vim.diagnostic.config({ + signs = true, + underline = true, + update_in_insert = true, + virtual_text = true, +}) + + +-- require("luasnip.loaders.from_vscode").lazy_load() +-- require("luasnip.loaders.from_snipmate").lazy_load() diff --git a/new/lua/plugins/mini.lua b/new/lua/plugins/mini.lua new file mode 100755 index 0000000..f8e79d0 --- /dev/null +++ b/new/lua/plugins/mini.lua @@ -0,0 +1,10 @@ +require("mini.ai").setup({ + custom_textobjects = { + [','] = require("mini.ai").gen_spec.pair(',', ',', {}), + ['9'] = require("mini.ai").gen_spec.pair('(', ',', {}), + ['0'] = require("mini.ai").gen_spec.pair(',', ')', {}), + } +}) +require("mini.jump").setup({}) +require("mini.sessions").setup({autowrite = false, directory = '~/.local/share/nvim/sessions'}) + diff --git a/new/lua/plugins/neotree.lua b/new/lua/plugins/neotree.lua new file mode 100755 index 0000000..905196a --- /dev/null +++ b/new/lua/plugins/neotree.lua @@ -0,0 +1,7 @@ +require("neo-tree").setup({ + source_selector = { + winbar = true, + statusline = false, + }, +}) + diff --git a/new/lua/plugins/none-ls.lua b/new/lua/plugins/none-ls.lua new file mode 100755 index 0000000..a5256d9 --- /dev/null +++ b/new/lua/plugins/none-ls.lua @@ -0,0 +1,16 @@ +local null_ls = require("null-ls") +null_ls.setup({ + sources = { + null_ls.builtins.formatting.stylua, + null_ls.builtins.formatting.shfmt, + null_ls.builtins.formatting.prettier, + null_ls.builtins.code_actions.gitsigns, + --null_ls.builtins.completion.luasnip, + null_ls.builtins.diagnostics.buf, + null_ls.builtins.formatting.biome, + null_ls.builtins.formatting.buf, + null_ls.builtins.formatting.fantomas, + null_ls.builtins.formatting.swift_format, + } +}) + diff --git a/new/lua/plugins/rust.lua b/new/lua/plugins/rust.lua new file mode 100755 index 0000000..a662fd8 --- /dev/null +++ b/new/lua/plugins/rust.lua @@ -0,0 +1,141 @@ +require("crates").setup { + smart_insert = true, + insert_closing_quote = true, + avoid_prerelease = true, + autoload = true, + autoupdate = true, + loading_indicator = true, + date_format = "%Y-%m-%d", + thousands_separator = ".", + notification_title = "Crates", + --curl_args = { "-sL", "--retry", "1" }, + disable_invalid_feature_diagnostic = false, + text = { + loading = "  Loading", + version = "  %s", + prerelease = "  %s", + yanked = "  %s", + nomatch = "  No match", + upgrade = "  %s", + error = "  Error fetching crate", + }, + highlight = { + loading = "CratesNvimLoading", + version = "CratesNvimVersion", + prerelease = "CratesNvimPreRelease", + yanked = "CratesNvimYanked", + nomatch = "CratesNvimNoMatch", + upgrade = "CratesNvimUpgrade", + error = "CratesNvimError", + }, + popup = { + autofocus = false, + copy_register = '"', + style = "minimal", + border = "none", + show_version_date = false, + show_dependency_version = true, + max_height = 30, + min_width = 20, + padding = 1, + text = { + title = " %s", + pill_left = "", + pill_right = "", + description = "%s", + created_label = " created ", + created = "%s", + updated_label = " updated ", + updated = "%s", + downloads_label = " downloads ", + downloads = "%s", + homepage_label = " homepage ", + homepage = "%s", + repository_label = " repository ", + repository = "%s", + documentation_label = " documentation ", + documentation = "%s", + crates_io_label = " crates.io ", + crates_io = "%s", + categories_label = " categories ", + keywords_label = " keywords ", + version = " %s", + prerelease = " %s", + yanked = " %s", + version_date = " %s", + feature = " %s", + enabled = " %s", + transitive = " %s", + normal_dependencies_title = " Dependencies", + build_dependencies_title = " Build dependencies", + dev_dependencies_title = " Dev dependencies", + dependency = " %s", + optional = " %s", + dependency_version = " %s", + loading = "  ", + }, + highlight = { + title = "CratesNvimPopupTitle", + pill_text = "CratesNvimPopupPillText", + pill_border = "CratesNvimPopupPillBorder", + description = "CratesNvimPopupDescription", + created_label = "CratesNvimPopupLabel", + created = "CratesNvimPopupValue", + updated_label = "CratesNvimPopupLabel", + updated = "CratesNvimPopupValue", + downloads_label = "CratesNvimPopupLabel", + downloads = "CratesNvimPopupValue", + homepage_label = "CratesNvimPopupLabel", + homepage = "CratesNvimPopupUrl", + repository_label = "CratesNvimPopupLabel", + repository = "CratesNvimPopupUrl", + documentation_label = "CratesNvimPopupLabel", + documentation = "CratesNvimPopupUrl", + crates_io_label = "CratesNvimPopupLabel", + crates_io = "CratesNvimPopupUrl", + categories_label = "CratesNvimPopupLabel", + keywords_label = "CratesNvimPopupLabel", + version = "CratesNvimPopupVersion", + prerelease = "CratesNvimPopupPreRelease", + yanked = "CratesNvimPopupYanked", + version_date = "CratesNvimPopupVersionDate", + feature = "CratesNvimPopupFeature", + enabled = "CratesNvimPopupEnabled", + transitive = "CratesNvimPopupTransitive", + normal_dependencies_title = "CratesNvimPopupNormalDependenciesTitle", + build_dependencies_title = "CratesNvimPopupBuildDependenciesTitle", + dev_dependencies_title = "CratesNvimPopupDevDependenciesTitle", + dependency = "CratesNvimPopupDependency", + optional = "CratesNvimPopupOptional", + dependency_version = "CratesNvimPopupDependencyVersion", + loading = "CratesNvimPopupLoading", + }, + keys = { + hide = { "q", "" }, + open_url = { "" }, + select = { "" }, + select_alt = { "s" }, + toggle_feature = { "" }, + copy_value = { "yy" }, + goto_item = { "gd", "K", "" }, + jump_forward = { "" }, + jump_back = { "", "" }, + }, + }, + src = { + insert_closing_quote = true, + text = { + prerelease = "  pre-release ", + yanked = "  yanked ", + }, + coq = { + enabled = false, + name = "Crates", + }, + }, + null_ls = { + enabled = false, + name = "Crates", + }, +} + diff --git a/new/lua/plugins/statusline.lua b/new/lua/plugins/statusline.lua new file mode 100755 index 0000000..5eadb34 --- /dev/null +++ b/new/lua/plugins/statusline.lua @@ -0,0 +1,773 @@ +local conditions = require("heirline.conditions") +local utils = require("heirline.utils") + +local colors = { + bright_bg = utils.get_highlight("Folded").bg, + bright_fg = utils.get_highlight("Folded").fg, + dark_bg = "#0c0c0c", + red = utils.get_highlight("DiagnosticError").fg, + dark_red = utils.get_highlight("DiffDelete").bg, + green = utils.get_highlight("String").fg, + blue = utils.get_highlight("Function").fg, + gray = utils.get_highlight("NonText").fg, + orange = utils.get_highlight("Constant").fg, + purple = utils.get_highlight("Statement").fg, + cyan = utils.get_highlight("Special").fg, + diag_warn = utils.get_highlight("DiagnosticWarn").fg, + diag_error = utils.get_highlight("DiagnosticError").fg, + diag_hint = utils.get_highlight("DiagnosticHint").fg, + diag_info = utils.get_highlight("DiagnosticInfo").fg, + git_del = utils.get_highlight("DiffRemoved").fg, + git_add = utils.get_highlight("DiffAdd").fg, + git_change = utils.get_highlight("DiffChanged").fg, +} + +require("heirline").load_colors(colors) + +local ViMode = { + -- get vim current mode, this information will be required by the provider + -- and the highlight functions, so we compute it only once per component + -- evaluation and store it as a component attribute + init = function(self) + self.mode = vim.fn.mode(1) -- :h mode() + end, + -- Now we define some dictionaries to map the output of mode() to the + -- corresponding string and color. We can put these into `static` to compute + -- them at initialisation time. + static = { + mode_names = { -- change the strings if you like it vvvvverbose! + n = "N", + no = "N?", + nov = "N?", + noV = "N?", + ["no\22"] = "N?", + niI = "Ni", + niR = "Nr", + niV = "Nv", + nt = "Nt", + v = "V", + vs = "Vs", + V = "V_", + Vs = "Vs", + ["\22"] = "^V", + ["\22s"] = "^V", + s = "S", + S = "S_", + ["\19"] = "^S", + i = "I", + ic = "Ic", + ix = "Ix", + R = "R", + Rc = "Rc", + Rx = "Rx", + Rv = "Rv", + Rvc = "Rv", + Rvx = "Rv", + c = "C", + cv = "Ex", + r = "...", + rm = "M", + ["r?"] = "?", + ["!"] = "!", + t = "T", + }, + mode_colors = { + n = "red" , + i = "green", + v = "cyan", + V = "cyan", + ["\22"] = "cyan", + c = "orange", + s = "purple", + S = "purple", + ["\19"] = "purple", + R = "orange", + r = "orange", + ["!"] = "red", + t = "red", + } + }, + -- We can now access the value of mode() that, by now, would have been + -- computed by `init()` and use it to index our strings dictionary. + -- note how `static` fields become just regular attributes once the + -- component is instantiated. + -- To be extra meticulous, we can also add some vim statusline syntax to + -- control the padding and make sure our string is always at least 2 + -- characters long. Plus a nice Icon. + provider = function(self) + --return "  %2("..self.mode_names[self.mode].."%)" + if self ~= nil then + if self.mode ~= nil then + local mn = self.mode_names[self.mode] + if mn ~= nil then + return "%2("..self.mode_names[self.mode].."%)" + end + end + end + --return "%2("..self.mode_names[self.mode].."%)" + end, + -- Same goes for the highlight. Now the foreground will change according to the current mode. + hl = function(self) + local mode = self.mode:sub(1, 1) -- get only the first mode character + return { fg = self.mode_colors[mode], bold = true, } + end, + -- Re-evaluate the component only on ModeChanged event! + -- Also allorws the statusline to be re-evaluated when entering operator-pending mode + update = { + "ModeChanged", + pattern = "*:*", + callback = vim.schedule_wrap(function() + vim.cmd("redrawstatus") + end), + }, +} + +ViMode = utils.surround({ "", "" }, "dark_bg", { ViMode}) + +local FileNameBlock = { + -- let's first set up some attributes needed by this component and it's children + init = function(self) + self.filename = vim.api.nvim_buf_get_name(0) + end, +} +-- We can now define some children separately and add them later + +local FileIcon = { + init = function(self) + local filename = self.filename + local extension = vim.fn.fnamemodify(filename, ":e") + self.icon, self.icon_color = require("nvim-web-devicons").get_icon_color(filename, extension, { default = true }) + end, + provider = function(self) + return self.icon and (self.icon .. " ") + end, + hl = function(self) + return { fg = self.icon_color } + end +} + +local FileName = { + provider = function(self) + -- first, trim the pattern relative to the current directory. For other + -- options, see :h filename-modifers + local filename = vim.fn.fnamemodify(self.filename, ":.") + if filename == "" then return "[No Name]" end + -- now, if the filename would occupy more than 1/4th of the available + -- space, we trim the file path to its initials + -- See Flexible Components section below for dynamic truncation + if not conditions.width_percent_below(#filename, 0.25) then + filename = vim.fn.pathshorten(filename) + end + return filename + end, + hl = { fg = utils.get_highlight("Directory").fg }, +} + +local FileFlags = { + { + condition = function() + return vim.bo.modified + end, + provider = "[+]", + hl = { fg = "green" }, + }, + { + condition = function() + return not vim.bo.modifiable or vim.bo.readonly + end, + provider = "", + hl = { fg = "orange" }, + }, +} + +-- Now, let's say that we want the filename color to change if the buffer is +-- modified. Of course, we could do that directly using the FileName.hl field, +-- but we'll see how easy it is to alter existing components using a "modifier" +-- component + +local FileNameModifer = { + hl = function() + if vim.bo.modified then + -- use `force` because we need to override the child's hl foreground + return { fg = "cyan", bold = true, force=true } + end + end, +} + +-- let's add the children to our FileNameBlock component +FileNameBlock = utils.insert(FileNameBlock, + FileIcon, + utils.insert(FileNameModifer, FileName), -- a new table where FileName is a child of FileNameModifier + FileFlags, + { provider = '%<'} -- this means that the statusline is cut here when there's not enough space +) + + + +local FileSize = { + provider = function() + -- stackoverflow, compute human readable file size + local suffix = { 'b', 'k', 'M', 'G', 'T', 'P', 'E' } + local fsize = vim.fn.getfsize(vim.api.nvim_buf_get_name(0)) + fsize = (fsize < 0 and 0) or fsize + if fsize < 1024 then + return fsize..suffix[1] + end + local i = math.floor((math.log(fsize) / math.log(1024))) + return string.format("%.2g%s", fsize / math.pow(1024, i), suffix[i + 1]) + end +} + +local FileLastModified = { + -- did you know? Vim is full of functions! + provider = function() + local ftime = vim.fn.getftime(vim.api.nvim_buf_get_name(0)) + return (ftime > 0) and os.date("%c", ftime) + end +} + +FileNameBlock = utils.surround({ "", "" }, "dark_bg", FileNameBlock) + +-- We're getting minimalists here! +local Ruler = { + -- %l = current line number + -- %L = number of lines in the buffer + -- %c = column number + -- %P = percentage through file of displayed window + provider = "%7(%l/%3L%):%2c %P", +} +Ruler = utils.surround({ "", "" }, "dark_bg", Ruler) + +-- I take no credits for this! :lion: +local ScrollBar ={ + static = { + sbar = { '▁', '▂', '▃', '▄', '▅', '▆', '▇', '█' } + -- Another variant, because the more choice the better. + -- sbar = { '🭶', '🭷', '🭸', '🭹', '🭺', '🭻' } + }, + provider = function(self) + local curr_line = vim.api.nvim_win_get_cursor(0)[1] + local lines = vim.api.nvim_buf_line_count(0) + local i = math.floor((curr_line - 1) / lines * #self.sbar) + 1 + return string.rep(self.sbar[i], 2) + end, + hl = { fg = "blue", bg = "dark_bg" }, +} + +local LSPActive = { + condition = conditions.lsp_attached, + update = {'LspAttach', 'LspDetach'}, + + -- You can keep it simple, + -- provider = " [LSP]", + + -- Or complicate things a bit and get the servers names + provider = function() + local names = {} + for i, server in pairs(vim.lsp.get_active_clients({ bufnr = 0 })) do + table.insert(names, server.name) + end + return " [" .. table.concat(names, " ") .. "]" + end, + hl = { fg = "green", bold = true }, +} + +LSPActive = utils.surround({ "", "" }, "dark_bg", LSPActive) + +-- Full nerd (with icon colors and clickable elements)! +-- works in multi window, but does not support flexible components (yet ...) +local Navic = { + condition = function() return require("nvim-navic").is_available() end, + static = { + -- create a type highlight map + type_hl = { + File = "Directory", + Module = "@include", + Namespace = "@namespace", + Package = "@include", + Class = "@structure", + Method = "@method", + Property = "@property", + Field = "@field", + Constructor = "@constructor", + Enum = "@field", + Interface = "@type", + Function = "@function", + Variable = "@variable", + Constant = "@constant", + String = "@string", + Number = "@number", + Boolean = "@boolean", + Array = "@field", + Object = "@type", + Key = "@keyword", + Null = "@comment", + EnumMember = "@field", + Struct = "@structure", + Event = "@keyword", + Operator = "@operator", + TypeParameter = "@type", + }, + -- bit operation dark magic, see below... + enc = function(line, col, winnr) + return bit.bor(bit.lshift(line, 16), bit.lshift(col, 6), winnr) + end, + -- line: 16 bit (65535); col: 10 bit (1023); winnr: 6 bit (63) + dec = function(c) + local line = bit.rshift(c, 16) + local col = bit.band(bit.rshift(c, 6), 1023) + local winnr = bit.band(c, 63) + return line, col, winnr + end + }, + init = function(self) + local data = require("nvim-navic").get_data() or {} + local children = {} + -- create a child for each level + for i, d in ipairs(data) do + -- encode line and column numbers into a single integer + local pos = self.enc(d.scope.start.line, d.scope.start.character, self.winnr) + local child = { + { + provider = d.icon, + hl = self.type_hl[d.type], + }, + { + -- escape `%`s (elixir) and buggy default separators + provider = d.name:gsub("%%", "%%%%"):gsub("%s*->%s*", ''), + -- highlight icon only or location name as well + -- hl = self.type_hl[d.type], + + on_click = { + -- pass the encoded position through minwid + minwid = pos, + callback = function(_, minwid) + -- decode + local line, col, winnr = self.dec(minwid) + vim.api.nvim_win_set_cursor(vim.fn.win_getid(winnr), {line, col}) + end, + name = "heirline_navic", + }, + }, + } + -- add a separator only if needed + if #data > 1 and i < #data then + table.insert(child, { + provider = " > ", + hl = { fg = 'bright_fg' }, + }) + end + table.insert(children, child) + end + -- instantiate the new child, overwriting the previous one + self.child = self:new(children, 1) + end, + -- evaluate the children containing navic components + provider = function(self) + return self.child:eval() + end, + hl = { fg = "gray" }, + update = 'CursorMoved' +} + +-- local Diagnostics = { +-- +-- condition = conditions.has_diagnostics, +-- +-- static = { +-- error_icon = vim.fn.sign_getdefined("DiagnosticSignError")[1].text, +-- warn_icon = vim.fn.sign_getdefined("DiagnosticSignWarn")[1].text, +-- info_icon = vim.fn.sign_getdefined("DiagnosticSignInfo")[1].text, +-- hint_icon = vim.fn.sign_getdefined("DiagnosticSignHint")[1].text, +-- }, +-- +-- init = function(self) +-- self.errors = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.ERROR }) +-- self.warnings = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.WARN }) +-- self.hints = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.HINT }) +-- self.info = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.INFO }) +-- end, +-- +-- update = { "DiagnosticChanged", "BufEnter" }, +-- +-- { +-- provider = function(self) +-- -- 0 is just another output, we can decide to print it or not! +-- return self.errors > 0 and (self.error_icon .. self.errors .. " ") +-- end, +-- hl = { fg = "diag_error" }, +-- }, +-- { +-- provider = function(self) +-- return self.warnings > 0 and (self.warn_icon .. self.warnings .. " ") +-- end, +-- hl = { fg = "diag_warn" }, +-- }, +-- { +-- provider = function(self) +-- return self.info > 0 and (self.info_icon .. self.info .. " ") +-- end, +-- hl = { fg = "diag_info" }, +-- }, +-- { +-- provider = function(self) +-- return self.hints > 0 and (self.hint_icon .. self.hints) +-- end, +-- hl = { fg = "diag_hint" }, +-- }, +-- } + +local Git = { + condition = conditions.is_git_repo, + + init = function(self) + self.status_dict = vim.b.gitsigns_status_dict + self.has_changes = self.status_dict.added ~= 0 or self.status_dict.removed ~= 0 or self.status_dict.changed ~= 0 + end, + + hl = { fg = "orange" }, + + + { -- git branch name + provider = function(self) + return " " .. self.status_dict.head + end, + hl = { bold = true } + }, + -- You could handle delimiters, icons and counts similar to Diagnostics + { + condition = function(self) + return self.has_changes + end, + provider = "(" + }, + { + provider = function(self) + local count = self.status_dict.added or 0 + return count > 0 and ("+" .. count) + end, + hl = { fg = "green" }, + }, + { + provider = function(self) + local count = self.status_dict.removed or 0 + return count > 0 and ("-" .. count) + end, + hl = { fg = "red" }, + }, + { + provider = function(self) + local count = self.status_dict.changed or 0 + return count > 0 and ("~" .. count) + end, + hl = { fg = "blue" }, + }, + { + condition = function(self) + return self.has_changes + end, + provider = ")", + }, +} + +local DAPMessages = { + condition = function() + local session = require("dap").session() + return session ~= nil + end, + provider = function() + return " " .. require("dap").status() + end, + hl = "Debug" + -- see Click-it! section for clickable actions +} + + +local WorkDir = { + provider = function() + local icon = (vim.fn.haslocaldir(0) == 1 and "l" or "g") .. " " .. " " + local cwd = vim.fn.getcwd(0) + cwd = vim.fn.fnamemodify(cwd, ":~") + if not conditions.width_percent_below(#cwd, 0.25) then + cwd = vim.fn.pathshorten(cwd) + end + local trail = cwd:sub(-1) == '/' and '' or "/" + return icon .. cwd .. trail + end, + hl = { fg = "blue", bold = true }, +} + +local TerminalName = { + -- we could add a condition to check that buftype == 'terminal' + -- or we could do that later (see #conditional-statuslines below) + provider = function() + local tname, _ = vim.api.nvim_buf_get_name(0):gsub(".*:", "") + return " " .. tname + end, + hl = { fg = "blue", bold = true }, +} + +------------------------------------------------------------------------------------- +local TablineBufnr = { + provider = function(self) + return tostring(self.bufnr) .. ". " + end, + hl = "Comment", +} + +-- we redefine the filename component, as we probably only want the tail and not the relative path +local TablineFileName = { + provider = function(self) + -- self.filename will be defined later, just keep looking at the example! + local filename = self.filename + filename = filename == "" and "[No Name]" or vim.fn.fnamemodify(filename, ":t") + return filename + end, + hl = function(self) + return { bold = self.is_active or self.is_visible, italic = true } + end, +} + +-- this looks exactly like the FileFlags component that we saw in +-- #crash-course-part-ii-filename-and-friends, but we are indexing the bufnr explicitly +-- also, we are adding a nice icon for terminal buffers. +local TablineFileFlags = { + { + condition = function(self) + return vim.api.nvim_buf_get_option(self.bufnr, "modified") + end, + provider = "[+]", + hl = { fg = "green" }, + }, + { + condition = function(self) + return not vim.api.nvim_buf_get_option(self.bufnr, "modifiable") + or vim.api.nvim_buf_get_option(self.bufnr, "readonly") + end, + provider = function(self) + if vim.api.nvim_buf_get_option(self.bufnr, "buftype") == "terminal" then + return "  " + else + return "" + end + end, + hl = { fg = "orange" }, + }, +} + +-- Here the filename block finally comes together +local TablineFileNameBlock = { + init = function(self) + self.filename = vim.api.nvim_buf_get_name(self.bufnr) + end, + hl = function(self) + if self.is_active then + return "TabLineSel" + -- why not? + -- elseif not vim.api.nvim_buf_is_loaded(self.bufnr) then + -- return { fg = "gray" } + else + return "TabLine" + end + end, + on_click = { + callback = function(_, minwid, _, button) + if (button == "m") then -- close on mouse middle click + vim.schedule(function() + vim.api.nvim_buf_delete(minwid, { force = false }) + end) + else + vim.api.nvim_win_set_buf(0, minwid) + end + end, + minwid = function(self) + return self.bufnr + end, + name = "heirline_tabline_buffer_callback", + }, + TablineBufnr, + FileIcon, -- turns out the version defined in #crash-course-part-ii-filename-and-friends can be reutilized as is here! + TablineFileName, + TablineFileFlags, +} + +-- a nice "x" button to close the buffer +local TablineCloseButton = { + condition = function(self) + return not vim.api.nvim_buf_get_option(self.bufnr, "modified") + end, + { provider = " " }, + { + provider = "", + hl = { fg = "gray" }, + on_click = { + callback = function(_, minwid) + vim.schedule(function() + vim.api.nvim_buf_delete(minwid, { force = false }) + end) + vim.cmd.redrawtabline() + end, + minwid = function(self) + return self.bufnr + end, + name = "heirline_tabline_close_buffer_callback", + }, + }, +} + +-- The final touch! +local TablineBufferBlock = utils.surround({ "", "" }, function(self) + if self.is_active then + return utils.get_highlight("TabLineSel").bg + else + return utils.get_highlight("TabLine").bg + end +end, { TablineFileNameBlock, TablineCloseButton }) + +-- and here we go +local BufferLine = utils.make_buflist( + TablineBufferBlock, + { provider = "", hl = { fg = "gray" } }, -- left truncation, optional (defaults to "<") + { provider = "", hl = { fg = "gray" } } -- right trunctation, also optional (defaults to ...... yep, ">") + -- by the way, open a lot of buffers and try clicking them ;) +) + +local Tabpage = { + provider = function(self) + return "%" .. self.tabnr .. "T " .. self.tabpage .. " %T" + end, + hl = function(self) + if not self.is_active then + return "TabLine" + else + return "TabLineSel" + end + end, +} + +local TabpageClose = { + provider = "%999X  %X", + hl = "TabLine", +} + +local TabPages = { + -- only show this component if there's 2 or more tabpages + condition = function() + return #vim.api.nvim_list_tabpages() >= 2 + end, + { provider = "%=" }, + utils.make_tablist(Tabpage), + TabpageClose, +} + +local TabLineOffset = { + condition = function(self) + local win = vim.api.nvim_tabpage_list_wins(0)[1] + local bufnr = vim.api.nvim_win_get_buf(win) + self.winid = win + + if vim.bo[bufnr].filetype == "NvimTree" then + self.title = "NvimTree" + return true + elseif vim.bo[bufnr].filetype == "neo-tree" then + self.title = "NeoTree" + return true + elseif vim.bo[bufnr].filetype == "nerdtree" then + self.title = "NerdTree" + return true + end + -- elseif vim.bo[bufnr].filetype == "TagBar" then + -- ... + end, + + provider = function(self) + local title = self.title + local width = vim.api.nvim_win_get_width(self.winid) + local pad = math.ceil((width - #title) / 2) + return string.rep(" ", pad) .. title .. string.rep(" ", pad) + end, + + hl = function(self) + if vim.api.nvim_get_current_win() == self.winid then + return "TablineSel" + else + return "Tabline" + end + end, +} + +local Align = { provider = "%=" } +local Space = { provider = " " } + +local StatusLine = { + ViMode, Space, FileNameBlock, Space, Git, Space, Align, + DAPMessages, Align, + LSPActive, Space, Ruler +} + +local WinBar = { + utils.surround({"", ""}, "#000000", Navic) +} + +local TabBar = { + TabLineOffset, BufferLine, TabPages, +} + +require("heirline").setup({ + statusline = StatusLine, + tabline = TabBar, + winbar = WinBar, + opts = { + disable_winbar_cb = function(args) + local buf = args.buf + local buftype = vim.tbl_contains({ "prompt", "nofile", "help", "quickfix" }, vim.bo[buf].buftype) + local filetype = vim.tbl_contains({ "gitcommit", "fugitive", "Trouble", "packer", "neo-tree", "nerdtree", "NvimTree" }, vim.bo[buf].filetype) + return buftype or filetype + end, + } +}) + +vim.o.showtabline = 2 +vim.o.laststatus = 3 + +-- require("lualine").setup { +-- options = { +-- icons_enabled = true, +-- theme = "auto", +-- component_separators = { left = "", right = ""}, +-- section_separators = { left = "", right = ""}, +-- disabled_filetypes = { +-- statusline = {}, +-- winbar = {}, +-- }, +-- ignore_focus = {}, +-- always_divide_middle = true, +-- globalstatus = false, +-- refresh = { +-- statusline = 1000, +-- tabline = 1000, +-- winbar = 1000, +-- } +-- }, +-- sections = { +-- lualine_a = {"mode"}, +-- lualine_b = {"diff"}, +-- lualine_c = {"branch"}, +-- lualine_x = {"location"}, +-- lualine_y = {"progress"}, +-- lualine_z = {"filename"} +-- }, +-- inactive_sections = { +-- lualine_a = {}, +-- lualine_b = {}, +-- lualine_c = {"filename"}, +-- lualine_x = {"location"}, +-- lualine_y = {}, +-- lualine_z = {} +-- }, +-- tabline = {}, +-- winbar = {}, +-- inactive_winbar = {}, +-- extensions = {} +-- } + diff --git a/new/lua/plugins/telescope.lua b/new/lua/plugins/telescope.lua new file mode 100755 index 0000000..218aa04 --- /dev/null +++ b/new/lua/plugins/telescope.lua @@ -0,0 +1,17 @@ +require "telescope".setup { + extensions = { + workspaces = { + keep_insert = true, + } + }, + pickers = { + colorscheme = { + enable_preview = true + } + } +} + +pcall(require("telescope").load_extension, "fzf") +require("telescope").load_extension("dap") +require("telescope").load_extension("harpoon") + diff --git a/new/lua/plugins/treesitter.lua b/new/lua/plugins/treesitter.lua new file mode 100755 index 0000000..981f608 --- /dev/null +++ b/new/lua/plugins/treesitter.lua @@ -0,0 +1,55 @@ +vim.filetype.add({extension = {wgsl = "wgsl"}}) + +require"nvim-treesitter.configs".setup { + ensure_installed = { "wgsl", "bash", "cmake", "cpp", "dockerfile", "gitignore", "glsl", "go", "graphql", "html", "java", "javascript", "json5", "kotlin", "markdown", "python", "rasi", "regex", "c", "lua", "rust", "scss", "sql", "sxhkdrc", "toml", "typescript", "yaml" }, + sync_install = false, + auto_install = true, + indent = { enable = true, disable = { 'python' } }, + highlight = { + enable = true, + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "gnn", + node_incremental = "grn", + scope_incremental = "grc", + node_decremental = "grm", + }, + }, + -- rainbow = { + -- enable = true, + -- -- list of languages you want to disable the plugin for + -- disable = {}, + -- -- Which query to use for finding delimiters + -- query = 'rainbow-parens', + -- -- Highlight the entire buffer all at once + -- strategy = require('ts-rainbow').strategy.global, + -- }, +} + +local treesitter_parser_config = require "nvim-treesitter.parsers".get_parser_configs() +treesitter_parser_config.templ = { + install_info = { + url = "https://github.com/vrischmann/tree-sitter-templ.git", + files = {"src/parser.c", "src/scanner.c"}, + branch = "master", + }, +} + +treesitter_parser_config.just = { + install_info = { + url = "https://github.com/IndianBoy42/tree-sitter-just", -- local path or git repo + files = { "src/parser.c", "src/scanner.cc" }, + branch = "main", + -- use_makefile = true -- this may be necessary on MacOS (try if you see compiler errors) + }, + maintainers = { "@IndianBoy42" }, +} + +vim.treesitter.language.register('templ', 'templ') + +vim.wo.foldmethod = "manual" +vim.wo.foldexpr = "nvim_treesitter#foldexpr()" +vim.o.foldlevelstart = 99 -- do not close folds when a buffer is opened +