diff options
-rw-r--r-- | after/plugin/conform.lua | 53 | ||||
-rw-r--r-- | after/plugin/dap.lua | 75 | ||||
-rw-r--r-- | after/plugin/gitsigns.lua | 25 | ||||
-rw-r--r-- | after/plugin/harpoon.lua | 34 | ||||
-rw-r--r-- | after/plugin/mini.lua | 14 | ||||
-rw-r--r-- | after/plugin/telescope.lua | 14 | ||||
-rw-r--r-- | after/plugin/treesitter.lua | 2 | ||||
-rw-r--r-- | init.lua | 1 | ||||
-rw-r--r-- | lua/config/autocmds.lua | 20 | ||||
-rw-r--r-- | lua/config/lazy.lua | 151 | ||||
-rw-r--r-- | lua/config/lsp.lua | 160 | ||||
-rw-r--r-- | lua/config/map.lua | 1 |
12 files changed, 17 insertions, 533 deletions
diff --git a/after/plugin/conform.lua b/after/plugin/conform.lua deleted file mode 100644 index 643743f..0000000 --- a/after/plugin/conform.lua +++ /dev/null @@ -1,53 +0,0 @@ -local conform = require("conform") -conform.setup({ - formatters_by_ft = { - lua = { "stylua" }, - -- html = { "prettier" }, - go = { "goimports", "gofmt" }, - }, - format_on_save = { - -- These options will be passed to conform.format() - timeout_ms = 500, - lsp_format = "never", - }, -}) - --- conform.formatters["clang-format"] = { --- prepend_args = { --- "--style", --- "{" --- .. "IndentWidth: 4, " --- .. "AlignAfterOpenBracket: BlockIndent, " --- .. "AlignArrayOfStructures: Right, " --- .. "BreakBeforeBraces: Linux, " --- .. "PointerAlignment: Left," --- .. "AllowShortIfStatementsOnASingleLine: true, " --- .. "AllowShortLoopsOnASingleLine: true, " --- .. "AllowAllArgumentsOnNextLine: true, " --- .. "AllowShortCaseLabelsOnASingleLine: true, " --- .. "AlwaysBreakAfterReturnType: AllDefinitions, " --- .. "ColumnLimit: " --- .. vim.o.tw --- .. "}", --- }, --- } - --- -- ID of autocmd for CFormat --- vim.b.CFormatID = nil --- -- Enable formatting on save for C only when using the :CFormat command --- vim.api.nvim_create_user_command("CFormat", function() --- if vim.b.CFormatID == nil then --- vim.b.CFormatID = vim.api.nvim_create_autocmd("BufWritePre", { --- buffer = 0, --- callback = function() --- conform.format({ formatters = { "clang-format" } }) --- end, --- }) --- conform.format({ formatters = { "clang-format" } }) --- print("Auto formatting enabled.") --- else --- vim.api.nvim_del_autocmd(vim.b.CFormatID) --- print("Auto formatting disabled.") --- vim.b.CFormatID = nil --- end --- end, {}) diff --git a/after/plugin/dap.lua b/after/plugin/dap.lua deleted file mode 100644 index fd141bb..0000000 --- a/after/plugin/dap.lua +++ /dev/null @@ -1,75 +0,0 @@ -local dap = require("dap") -local dapui = require("dapui") -local widgets = require("dap.ui.widgets") -local map = vim.keymap.set - -dapui.setup() --- stylua: ignore start -map("n", " bu", function() dapui.toggle() end, { desc = "Toggle dap-ui" }) -map("n", " bb", function() dap.toggle_breakpoint() end, { desc = "Toggle breakpoint" }) -map("n", " bc", function() dap.continue() end, {desc="Continue"}) -map("n", " bs", function() dap.step_over() end, {desc="Step over"}) -map("n", " bi", function() dap.step_into() end, {desc="Step into"}) -map("n", " bo", function() dap.step_out() end, {desc="Step out"}) -map({ "n", "v" }, " bh", function() widgets.hover() end, {desc="Show hover"}) -map({ "n", "v" }, " bv", function() widgets.preview() end, {desc="Show preview"}) -map("n", " bf", function() widgets.centered_float(widgets.frames) end, {desc="Show frames"}) -map("n", " bp", function() widgets.centered_float(widgets.scopes) end, {desc="Show scopes"}) --- stylua: ignore end -map("n", " bl", function() - dap.set_breakpoint(nil, nil, vim.fn.input("Log point message: ")) -end, { desc = "Break point with log" }) - -dap.adapters.gdb = { - id = "gdb", - type = "executable", - command = "gdb", - args = { "--quiet", "--interpreter=dap" }, -} - -dap.configurations.c = { - { - name = "Run (GDB)", - type = "gdb", - request = "launch", - -- This requires special handling of 'run_last', see - -- https://github.com/mfussenegger/nvim-dap/issues/1025#issuecomment-1695852355 - program = function() - local path = vim.fn.input({ - prompt = "Path to executable: ", - default = vim.fn.getcwd() .. "/", - completion = "file", - }) - - return (path and path ~= "") and path or dap.ABORT - end, - }, - { - name = "Run with arguments (GDB)", - type = "gdb", - request = "launch", - -- This requires special handling of 'run_last', see - -- https://github.com/mfussenegger/nvim-dap/issues/1025#issuecomment-1695852355 - program = function() - local path = vim.fn.input({ - prompt = "Path to executable: ", - default = vim.fn.getcwd() .. "/", - completion = "file", - }) - - return (path and path ~= "") and path or dap.ABORT - end, - args = function() - local args_str = vim.fn.input({ - prompt = "Arguments: ", - }) - return vim.split(args_str, " +") - end, - }, - { - name = "Attach to process (GDB)", - type = "gdb", - request = "attach", - processId = require("dap.utils").pick_process, - }, -} diff --git a/after/plugin/gitsigns.lua b/after/plugin/gitsigns.lua deleted file mode 100644 index 46536b1..0000000 --- a/after/plugin/gitsigns.lua +++ /dev/null @@ -1,25 +0,0 @@ -local gitsigns = require("gitsigns") -gitsigns.setup({ - signs = { - add = { text = "▎" }, - change = { text = "▎" }, - delete = { text = "▎" }, - topdelete = { text = "▎" }, - changedelete = { text = "▎" }, - untracked = { text = "▎" }, - }, - numhl = false, - attach_to_untracked = true, - update_debounce = 0, - on_attach = function() - local map = vim.keymap.set - -- stylua: ignore start - map("n", "]g", gitsigns.next_hunk, { desc = "Next git hunk" }) - map("n", "[g", gitsigns.prev_hunk, { desc = "Previous git hunk" }) - map("n", " gd", gitsigns.toggle_deleted, { desc="Toggle deleted"}) - map("n", " gr", gitsigns.reset_hunk, { desc="Reset hunk"}) - map("n", " gs", gitsigns.stage_hunk, { desc="Stage hunk"}) - map("n", " gu", gitsigns.undo_stage_hunk, { desc="Undo stage hunk"}) - map("n", " gb", gitsigns.blame, { desc="Blame"}) - end, -}) diff --git a/after/plugin/harpoon.lua b/after/plugin/harpoon.lua deleted file mode 100644 index 999b957..0000000 --- a/after/plugin/harpoon.lua +++ /dev/null @@ -1,34 +0,0 @@ -local harpoon = require("harpoon") -local map = vim.keymap.set - --- REQUIRED -harpoon:setup() - -map("n", "<C-h>", function() - harpoon.ui:toggle_quick_menu(harpoon:list()) -end, { desc = "Harpoon pick menu" }) - -map("n", " ha", function() - harpoon:list():add() - print("Added to harpoon.") -end, { desc = "Harpoon add" }) -map("n", " h1", function() - harpoon:list():select(1) -end, { desc = "Harpoon 1" }) -map("n", " h2", function() - harpoon:list():select(2) -end, { desc = "Harpoon 2" }) -map("n", " h3", function() - harpoon:list():select(3) -end, { desc = "Harpoon 3" }) -map("n", " h4", function() - harpoon:list():select(4) -end, { desc = "Harpoon 4" }) - --- Toggle previous & next buffers stored within Harpoon list -map("n", " hp", function() - harpoon:list():prev() -end, { desc = "Harpoon previous" }) -map("n", " hn", function() - harpoon:list():next() -end, { desc = "Harpoon next" }) diff --git a/after/plugin/mini.lua b/after/plugin/mini.lua index 6a35641..2ef3eff 100644 --- a/after/plugin/mini.lua +++ b/after/plugin/mini.lua @@ -5,12 +5,12 @@ require("mini.statusline").setup({ require("mini.surround").setup({ silent = true, mappings = { - add = "gsa", -- Add surrounding in Normal and Visual modes - delete = "gsd", -- Delete surrounding - find = "gsf", -- Find surrounding (to the right) - find_left = "gsF", -- Find surrounding (to the left) - highlight = "gsh", -- Highlight surrounding - replace = "gsr", -- Replace surrounding - update_n_lines = "gsn", -- Update `n_lines` + add = "gsa", + delete = "gsd", + find = "gsf", + find_left = "gsF", + highlight = "gsh", + replace = "gsr", + update_n_lines = "gsn", }, }) diff --git a/after/plugin/telescope.lua b/after/plugin/telescope.lua index c77e464..b481fa3 100644 --- a/after/plugin/telescope.lua +++ b/after/plugin/telescope.lua @@ -1,5 +1,8 @@ +local telescope = require("telescope") +local builtin = require("telescope.builtin") local map = vim.keymap.set -require("telescope").setup({ + +telescope.setup({ defaults = { path_display = { shorten = { @@ -23,17 +26,18 @@ require("telescope").setup({ }, }) -local builtin = require("telescope.builtin") map("n", " ff", builtin.find_files) -map("n", " bl", builtin.buffers) +map("n", " fb", builtin.buffers) map("n", " fp", builtin.git_files) map("n", " fw", builtin.live_grep) map("n", " fh", builtin.help_tags) +map("n", " fk", builtin.keymaps) +map("n", " fs", builtin.spell_suggest) -- symbols map("n", " fe", "<cmd>lua require'telescope.builtin'.symbols{ sources = {'emoji', 'gitmoji'} }<CR>") map("n", " fn", "<cmd>lua require'telescope.builtin'.symbols{ sources = {'nerd'} }<CR>") map("n", " fj", "<cmd>lua require'telescope.builtin'.symbols{ sources = {'julia'} }<CR>") +map("n", " ft", "<cmd>lua require'telescope.builtin'.treesitter{ symbols = {'function'} }<CR>") -require("telescope").load_extension("ui-select") -require("telescope").load_extension("fzf") +telescope.load_extension("fzf") diff --git a/after/plugin/treesitter.lua b/after/plugin/treesitter.lua index a0e8014..a625f4c 100644 --- a/after/plugin/treesitter.lua +++ b/after/plugin/treesitter.lua @@ -20,5 +20,3 @@ require("nvim-treesitter.configs").setup({ }, }, }) --- vim.api.nvim_buf_create_user_command --- vim.keymap.set("n", "") @@ -1,6 +1,5 @@ require("config.lazy") require("config.set") require("config.map") -require("config.lsp") require("config.autocmds") require("config.projects") diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua index f6033d6..1a4970b 100644 --- a/lua/config/autocmds.lua +++ b/lua/config/autocmds.lua @@ -33,14 +33,6 @@ autocmd("TermOpen", { vim.keymap.set("t", "<Esc>", "<C-\\><C-n>", { noremap = true }) end, }) --- -- close automatically when shell process exits --- -- TODO: does not work --- autocmd("TermClose", { --- callback = function() --- vim.cmd("bdelete") --- end, --- }) -vim.keymap.set("n", "!", "<cmd>sp<CR><cmd>term<CR>", { desc = "Open terminal" }) -- [[ preserve last position ]] autocmd("BufReadPost", { @@ -72,17 +64,5 @@ autocmd( } ) --- autocmd({ "BufNewFile", "BufRead" }, { --- pattern = "*", --- callback = function() --- local output = vim.fn.system("git rev-parse --is-inside-work-tree") --- if output == "true\n" then --- vim.opt.signcolumn = "yes" --- else --- vim.opt.signcolumn = "no" --- end --- end, --- }) - -- Automatically resize panes autocmd("VimResized", { pattern = "*", command = "wincmd =" }) diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua index 1bd0b8a..4ced567 100644 --- a/lua/config/lazy.lua +++ b/lua/config/lazy.lua @@ -15,123 +15,8 @@ vim.opt.rtp:prepend(lazypath) -- plugins installation and configuration require("lazy").setup({ "echasnovski/mini.nvim", - "tpope/vim-fugitive", - "lewis6991/gitsigns.nvim", "tpope/vim-vinegar", - "tpope/vim-eunuch", - -- "mg979/vim-visual-multi", - { - "brenton-leighton/multiple-cursors.nvim", - version = "*", -- Use the latest tagged version - opts = { - custom_key_maps = { - { - "n", - "<S-Tab>", - function() - require("multiple-cursors").align() - end, - }, - }, - }, - keys = { - { "<C-j>", "<Cmd>MultipleCursorsAddDown<CR>", mode = { "n", "x" }, desc = "Add cursor and move down" }, - { "<C-k>", "<Cmd>MultipleCursorsAddUp<CR>", mode = { "n", "x" }, desc = "Add cursor and move up" }, - - { "<C-Up>", "<Cmd>MultipleCursorsAddUp<CR>", mode = { "n", "i", "x" }, desc = "Add cursor and move up" }, - { - "<C-Down>", - "<Cmd>MultipleCursorsAddDown<CR>", - mode = { "n", "i", "x" }, - desc = "Add cursor and move down", - }, - - { - "<Leader>m", - "<Cmd>MultipleCursorsAddVisualArea<CR>", - mode = { "x" }, - desc = "Add cursors to the lines of the visual area", - }, - - { "<Leader>a", "<Cmd>MultipleCursorsAddMatches<CR>", mode = { "n", "x" }, desc = "Add cursors to cword" }, - { - "<Leader>A", - "<Cmd>MultipleCursorsAddMatchesV<CR>", - mode = { "n", "x" }, - desc = "Add cursors to cword in previous area", - }, - - { - "<Leader>d", - "<Cmd>MultipleCursorsAddJumpNextMatch<CR>", - mode = { "n", "x" }, - desc = "Add cursor and jump to next cword", - }, - { "<Leader>D", "<Cmd>MultipleCursorsJumpNextMatch<CR>", mode = { "n", "x" }, desc = "Jump to next cword" }, - - { "<Leader>l", "<Cmd>MultipleCursorsLock<CR>", mode = { "n", "x" }, desc = "Lock virtual cursors" }, - }, - }, - "jghauser/follow-md-links.nvim", - "stevearc/conform.nvim", "norcalli/nvim-colorizer.lua", - "neovim/nvim-lspconfig", - { - "williamboman/mason.nvim", - dependencies = { - "williamboman/mason-lspconfig.nvim", - -- for formatters and linters - "WhoIsSethDaniel/mason-tool-installer.nvim", - }, - config = function() - require("mason").setup({ - ui = { - border = "rounded", - }, - }) - end, - }, - { - --snippets - "L3MON4D3/LuaSnip", - version = "v2.*", - build = "make install_jsregexp", - }, - -- "mfussenegger/nvim-lint", - -- { - -- "ray-x/lsp_signature.nvim", - -- event = "LspAttach", - -- }, - -- { - -- "hrsh7th/nvim-cmp", - -- dependencies = { - -- "hrsh7th/cmp-nvim-lsp", - -- "hrsh7th/cmp-path", - -- "hrsh7th/cmp-buffer", - -- "saadparwaiz1/cmp_luasnip", - -- "onsails/lspkind.nvim", - -- }, - -- event = { "InsertEnter", "CmdlineEnter" }, - -- }, - { - "folke/which-key.nvim", - event = "VeryLazy", - opts = { - win = { - border = "rounded", - }, - }, - keys = { - { - "<leader>?", - function() - require("which-key").show({ global = false }) - end, - desc = "Buffer Local Keymaps (which-key)", - }, - }, - }, - { "christoomey/vim-tmux-navigator", cmd = { @@ -151,29 +36,6 @@ require("lazy").setup({ }, { - "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 - }, - - { - "dstein64/vim-startuptime", - cmd = "StartupTime", - init = function() - vim.g.startuptime_tries = 10 - end, - }, - - { "gbprod/nord.nvim", lazy = false, priority = 1000, @@ -220,19 +82,6 @@ require("lazy").setup({ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate", }, - { - "ThePrimeagen/harpoon", - branch = "harpoon2", - requires = { "nvim-lua/plenary.nvim", lazy = true }, - }, - - -- DAP - { - { - "mfussenegger/nvim-dap", - }, - { "rcarriga/nvim-dap-ui", dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" } }, - }, }, { -- lazy options diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua deleted file mode 100644 index 10235bf..0000000 --- a/lua/config/lsp.lua +++ /dev/null @@ -1,160 +0,0 @@ --- [[ Keybinds ]] -local diagnostic = vim.diagnostic -local lbuf = vim.lsp.buf -local map = vim.keymap.set -local builtin = require("telescope.builtin") - -map("n", " <cr>", lbuf.code_action, { desc = "Code actions" }) -map("n", "gd", lbuf.definition, { desc = "Definition" }) -map("i", "<C-k>", lbuf.hover) -map("n", " lr", lbuf.rename, { desc = "Rename" }) -map("n", " li", builtin.lsp_implementations, { desc = "Implementation" }) -map("n", " ls", lbuf.signature_help, { desc = "Signature help" }) -map("n", " lh", lbuf.typehierarchy, { desc = "Type hierarchy" }) -map("n", " lf", lbuf.references, { desc = "References" }) -map("n", " ll", lbuf.document_symbol, { desc = "List symbols" }) -map("n", " lt", lbuf.type_definition, { desc = "Type definition" }) --- map("n", " lls", vim.lsp.handlers["workspace/symbol"]) -map("n", " lq", diagnostic.setqflist, { desc = "Diagnostic quickfix" }) -map("n", " >>", diagnostic.goto_next, { desc = "Diagnostic next" }) -map("n", " <<", diagnostic.goto_prev, { desc = "Diagnostic prev" }) -map("n", " <,", function() - diagnostic.goto_next({ severity = diagnostic.ERROR }) -end, { desc = "Diagnostic next error" }) -map("n", " >.", function() - diagnostic.goto_prev({ severity = diagnostic.ERROR }) -end, { desc = "Diagnostic prev error" }) -map("n", " vf", diagnostic.open_float, { desc = "Diagnostics open floating window" }) --- map("n", " ") - --- vim.lsp.inlay_hint(0, false) - --- [[ LSP Setups ]] - -local lspconfig = require("lspconfig") -lspconfig.gopls.setup({}) --- lspconfig.clangd.setup({}) --- lspconfig.emmet_ls.setup({}) --- lspconfig.ts_ls.setup({}) --- lspconfig.powershell_es.setup({ --- cmd = { --- "pwsh", --- "-NoLog", --- "-NoProfile", --- "-Command", --- "/home/aluc/.local/share/nvim/mason/packages/" .. --- "powershell-editor-services/PowerShellEditorServices/Start-EditorServices.ps1", --- }, --- }) --- lspconfig.lua_ls.setup({ --- -- with neovim support --- on_init = function(client) --- local path = client.workspace_folders[1].name --- if vim.loop.fs_stat(path .. "/.luarc.json") or vim.loop.fs_stat(path .. "/.luarc.jsonc") then --- return --- end --- --- client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, { --- runtime = { --- version = "LuaJIT", --- }, --- -- Make the server aware of Neovim runtime files --- workspace = { --- checkThirdParty = false, --- library = { --- vim.env.VIMRUNTIME, --- }, --- }, --- }) --- end, --- settings = { --- Lua = {}, --- }, --- }) - --- rounded border around floating windows -local _border = "rounded" -vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { - border = _border, -}) -vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { - border = _border, -}) -vim.diagnostic.config({ - float = { border = _border }, -}) - -local autocmd = vim.api.nvim_create_autocmd -autocmd("LspAttach", { - callback = function(args) - local client = vim.lsp.get_client_by_id(args.data.client_id) - if client == nil then - return - end - if vim.tbl_contains({ "null-ls" }, client.name) then -- blacklist lsp - return - end - end, -}) - -local ls = require("luasnip") - -local parse_snippet = ls.parser.parse_snippet - -map({ "i", "s" }, "<C-h>", function() - if ls.expand_or_locally_jumpable() then - ls.expand_or_jump() - end -end, { silent = true }) -map({ "i", "s" }, "<C-l>", function() - if ls.locally_jumpable(-1) then - ls.jump(-1) - end -end, { silent = true }) -map({ "i", "s" }, "<C-c>", function() - if ls.choice_active() then - ls.change_choice(1) - end -end, { silent = true }) - -ls.config.set_config({ - history = true, - -- Will update multiple nodes at the same time when in insert mode - update_events = { "TextChanged", "TextChangedI" }, -}) - -ls.add_snippets("go", { - parse_snippet("main", "package main\n\nfunc main() {\n\t$0\n}"), - parse_snippet("e", "if err != nil {\n\tpanic(err)$1\n}$0"), - parse_snippet("ee", "if err != nil {\n\tfmt.Fprintln(os.Stderr, err)$1\n\tos.Exit(${2:1})\n}\n$0"), - parse_snippet("eif", "if err := $1; err != nil {\n\tfmt.Println(err)$2\n}\n$0"), - parse_snippet("pf", "fmt.Printf($0)"), - parse_snippet("pl", "fmt.Println($0)"), -}) -ls.add_snippets("sh", { - parse_snippet("!", "#!/bin/sh\n$0"), - parse_snippet("if", "if ${1:condition}; then\n\t$0\nfi"), - parse_snippet("while", "while ${1:condition}; do\n\t$0\ndone"), - parse_snippet("for", "for ${1:v} in ${2:list}; do\n\t$0\ndone"), - parse_snippet("case", "case ${1:\\$var} in\n\t$0\nesac"), -}) -ls.add_snippets("c", { - parse_snippet("main", "int\nmain(int Argc, char *Args[])\n{\n\t$0\n\treturn 0;\n}"), - parse_snippet( - "uints", - [[#include <stdint.h> -typedef uint8_t u8; -typedef uint16_t u16; -typedef uint32_t u32; -typedef uint64_t u64; -typedef int8_t i8; -typedef int16_t i16; -typedef int32_t i32; -typedef int64_t i64; -typedef float f32; -typedef double f64; -]] - ), -}) -ls.add_snippets("typescript", { parse_snippet("cl", "console.log($0);") }) -ls.add_snippets("html", { parse_snippet("t", [[<$1>$0</$1>]]) }) diff --git a/lua/config/map.lua b/lua/config/map.lua index 27c6bb9..fe0672c 100644 --- a/lua/config/map.lua +++ b/lua/config/map.lua @@ -38,6 +38,7 @@ map("n", " Q", "<cmd>qa!<cr>", { noremap = true }) map("n", " 1", "<cmd>%bd|e#<cr>", { noremap = true }) -- next tab map("n", "+", "<cmd>tabe .<cr>", { noremap = true }) +map("n", "!", "<cmd>sp<CR><cmd>term<CR>", { desc = "Open terminal" }) -- better indenting map("v", "<", "<gv") |