diff --git a/nvim/m-housh/lua/user/plugin/cmp.lua b/nvim/m-housh/lua/user/plugin/cmp.lua index f228f41..e405003 100755 --- a/nvim/m-housh/lua/user/plugin/cmp.lua +++ b/nvim/m-housh/lua/user/plugin/cmp.lua @@ -1,117 +1,182 @@ return { - "hrsh7th/nvim-cmp", - enabled = true, - dependencies = { - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - "hrsh7th/cmp-cmdline", - "hrsh7th/cmp-vsnip", - "hrsh7th/vim-vsnip", - 'saadparwaiz1/cmp_luasnip', - "f3fora/cmp-spell", - "hrsh7th/cmp-calc", - "hrsh7th/cmp-emoji", - "L3MON4D3/LuaSnip", - -- Adds a number of user-friendly snippets - 'rafamadriz/friendly-snippets', - "onsails/lspkind.nvim", -- vs-code like pictograms - }, - event = { 'BufReadPre', 'BufNewFile' }, - config = function() - -- Setup nvim-cmp. - local cmp = require "cmp" - local lspkind = require("lspkind") - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) - local luasnip = require('luasnip') + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + "hrsh7th/cmp-buffer", -- source for text in buffer + "hrsh7th/cmp-path", -- source for file system paths + "L3MON4D3/LuaSnip", -- snippet engine + "saadparwaiz1/cmp_luasnip", -- for autocompletion + "rafamadriz/friendly-snippets", -- useful snippets + "onsails/lspkind.nvim", -- vs-code like pictograms + }, + config = function() + local cmp = require("cmp") + local luasnip = require("luasnip") + local lspkind = require("lspkind") - require('lspconfig').sourcekit.setup { - capabilities = capabilities - } - require("luasnip.loaders.from_vscode").lazy_load() + -- loads vscode style snippets from installed plugins (e.g. friendly-snippets) + require("luasnip.loaders.from_vscode").lazy_load() - - lspkind.init({ - symbol_map = { - - Text = "", - Method = "󰡱", - Function = "󰡱", - Constructor = "", - Field = "ﰠ", - Variable = "", - Class = "ﴯ", - Interface = "", - Module = "", - Property = "ﰠ", - Unit = "塞", - Value = "", - Enum = "", - Keyword = "", - Snippet = "", - Color = "", - File = "", - Reference = "", - Folder = "", - EnumMember = "", - Constant = "", - Struct = "פּ", - Event = "", - Operator = "", - TypeParameter = "" - } - }) - - cmp.setup({ - completion = { - completeopt = "menu,menuone,preview", - }, - snippet = { -- configure how nvim-cmp interacts with snippet engine - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.select_prev_item(), -- previous suggestion - [""] = cmp.mapping.select_next_item(), -- next suggestion - [""] = cmp.mapping.complete(), -- show completion suggestions - [""] = cmp.mapping.abort(), -- close completion window - [""] = cmp.mapping.confirm({ select = false, behavior = cmp.ConfirmBehavior.Replace }), - [""] = cmp.mapping(function(fallback) - if luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) - if luasnip.jumpable(1) then - luasnip.jump(1) - else - fallback() - end - end, { "i", "s" }), - }), - -- sources for autocompletion - sources = cmp.config.sources({ - { name = "nvim_lsp" }, - { name = "luasnip" }, -- snippets - { name = "buffer" }, -- text within current buffer - { name = "path" }, -- file system paths - { name = "calc" }, - { name = "emoji" }, - { name = "spell" }, - }), - -- configure lspkind for vs-code like pictograms in completion menu - formatting = { - expandable_indicator = true, - fields = { 'abbr', 'kind', 'menu' }, - format = lspkind.cmp_format({ - maxwidth = 50, - ellipsis_char = "...", - }), - }, - }) - end, + cmp.setup({ + completion = { + completeopt = "menu,menuone,preview", + }, + snippet = { -- configure how nvim-cmp interacts with snippet engine + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_prev_item(), -- previous suggestion + [""] = cmp.mapping.select_next_item(), -- next suggestion + [""] = cmp.mapping.complete(), -- show completion suggestions + [""] = cmp.mapping.abort(), -- close completion window + [""] = cmp.mapping.confirm({ select = false, behavior = cmp.ConfirmBehavior.Replace }), + [""] = cmp.mapping(function(fallback) + if luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if luasnip.jumpable(1) then + luasnip.jump(1) + else + fallback() + end + end, { "i", "s" }), + }), + -- sources for autocompletion + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, -- snippets + { name = "buffer" }, -- text within current buffer + { name = "path" }, -- file system paths + }), + -- configure lspkind for vs-code like pictograms in completion menu + formatting = { + format = lspkind.cmp_format({ + maxwidth = 50, + ellipsis_char = "...", + }), + }, + }) + end, } +-- return { +-- "hrsh7th/nvim-cmp", +-- enabled = true, +-- dependencies = { +-- "hrsh7th/cmp-nvim-lsp", +-- "hrsh7th/cmp-buffer", +-- "hrsh7th/cmp-path", +-- "hrsh7th/cmp-cmdline", +-- "hrsh7th/cmp-vsnip", +-- "hrsh7th/vim-vsnip", +-- "saadparwaiz1/cmp_luasnip", +-- "f3fora/cmp-spell", +-- "hrsh7th/cmp-calc", +-- "hrsh7th/cmp-emoji", +-- "L3MON4D3/LuaSnip", +-- -- Adds a number of user-friendly snippets +-- "rafamadriz/friendly-snippets", +-- "onsails/lspkind.nvim", -- vs-code like pictograms +-- }, +-- event = { "BufReadPre", "BufNewFile" }, +-- config = function() +-- -- Setup nvim-cmp. +-- local cmp = require("cmp") +-- local lspkind = require("lspkind") +-- local capabilities = vim.lsp.protocol.make_client_capabilities() +-- capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities) +-- local luasnip = require("luasnip") +-- require("luasnip.loaders.from_vscode").lazy_load() +-- +-- require("lspconfig").sourcekit.setup({ +-- capabilities = capabilities, +-- }) +-- +-- lspkind.init({ +-- symbol_map = { +-- +-- Text = "", +-- Method = "󰡱", +-- Function = "󰡱", +-- Constructor = "", +-- Field = "ﰠ", +-- Variable = "", +-- Class = "ﴯ", +-- Interface = "", +-- Module = "", +-- Property = "ﰠ", +-- Unit = "塞", +-- Value = "", +-- Enum = "", +-- Keyword = "", +-- Snippet = "", +-- Color = "", +-- File = "", +-- Reference = "", +-- Folder = "", +-- EnumMember = "", +-- Constant = "", +-- Struct = "פּ", +-- Event = "", +-- Operator = "", +-- TypeParameter = "", +-- }, +-- }) +-- +-- cmp.setup({ +-- completion = { +-- completeopt = "menu,menuone,preview", +-- }, +-- snippet = { -- configure how nvim-cmp interacts with snippet engine +-- expand = function(args) +-- luasnip.lsp_expand(args.body) +-- end, +-- }, +-- mapping = cmp.mapping.preset.insert({ +-- [""] = cmp.mapping.select_prev_item(), -- previous suggestion +-- [""] = cmp.mapping.select_next_item(), -- next suggestion +-- [""] = cmp.mapping.complete(), -- show completion suggestions +-- [""] = cmp.mapping.abort(), -- close completion window +-- [""] = cmp.mapping.confirm({ select = false, behavior = cmp.ConfirmBehavior.Replace }), +-- [""] = cmp.mapping(function(fallback) +-- if luasnip.jumpable(-1) then +-- luasnip.jump(-1) +-- else +-- fallback() +-- end +-- end, { "i", "s" }), +-- [""] = cmp.mapping(function(fallback) +-- if luasnip.jumpable(1) then +-- luasnip.jump(1) +-- else +-- fallback() +-- end +-- end, { "i", "s" }), +-- }), +-- -- sources for autocompletion +-- sources = cmp.config.sources({ +-- { name = "nvim_lsp" }, +-- { name = "luasnip" }, -- snippets +-- { name = "buffer" }, -- text within current buffer +-- { name = "path" }, -- file system paths +-- --{ name = "calc" }, +-- --{ name = "emoji" }, +-- --{ name = "spell" }, +-- }), +-- -- configure lspkind for vs-code like pictograms in completion menu +-- formatting = { +-- expandable_indicator = true, +-- fields = { "abbr", "kind", "menu" }, +-- format = lspkind.cmp_format({ +-- maxwidth = 50, +-- ellipsis_char = "...", +-- }), +-- }, +-- }) +-- end, +-- } diff --git a/nvim/m-housh/lua/user/plugin/fidget.lua b/nvim/m-housh/lua/user/plugin/fidget.lua new file mode 100644 index 0000000..9adf66a --- /dev/null +++ b/nvim/m-housh/lua/user/plugin/fidget.lua @@ -0,0 +1,23 @@ +return { + "j-hui/fidget.nvim", + event = "VeryLazy", + config = function() + local fidget = require("fidget") + fidget.setup({ + notification = { + window = { + normal_hl = "String", -- Base highlight group in the notification window + winblend = 0, -- Background color opacity in the notification window + border = "rounded", -- Border around the notification window + zindex = 45, -- Stacking priority of the notification window + max_width = 0, -- Maximum width of the notification window + max_height = 0, -- Maximum height of the notification window + x_padding = 1, -- Padding from right edge of window boundary + y_padding = 1, -- Padding from bottom edge of window boundary + align = "bottom", -- How to align the notification window + relative = "editor", -- What the notification window position is relative to + }, + }, + }) + end, +} diff --git a/nvim/m-housh/lua/user/plugin/formatter.lua b/nvim/m-housh/lua/user/plugin/formatter.lua index d17921e..30ff6aa 100755 --- a/nvim/m-housh/lua/user/plugin/formatter.lua +++ b/nvim/m-housh/lua/user/plugin/formatter.lua @@ -1,55 +1,69 @@ return { - "mhartington/formatter.nvim", - event = { 'BufReadPre', 'BufNewFile' }, - config = function() - local util = require("formatter.util") - require("formatter").setup({ - filetype = { - markdown = function() - return { - exe = "prettier", - args = { - "--stdin-filepath", - util.escape_path(util.get_current_buffer_file_path()), - "--print-width", - "80", - "--prose-wrap", - "always", - "--parser", - "markdown" - }, - stdin = true, - try_node_modules = true, - } - end, - swift = function() - return { - exe = "swiftformat", - } - end, - ["*"] = { - -- formatter for any / all file types. - require("formatter.filetypes.any").remove_trailing_whitespace - } - } - }) + "mhartington/formatter.nvim", + event = { "BufReadPre", "BufNewFile" }, + config = function() + local util = require("formatter.util") + require("formatter").setup({ + filetype = { + lua = { + require("formatter.filetypes.lua").stylua, + function() + return { + exe = "stylua", + args = { + "--search-parent-directories", + "--stdin-filepath", + util.escape_path(util.get_current_buffer_file_path()), + "--", + "-", + }, + stdin = true, + } + end, + }, + markdown = function() + return { + exe = "prettier", + args = { + "--stdin-filepath", + util.escape_path(util.get_current_buffer_file_path()), + "--print-width", + "80", + "--prose-wrap", + "always", + "--parser", + "markdown", + }, + stdin = true, + try_node_modules = true, + } + end, + swift = function() + return { + exe = "swiftformat", + } + end, + ["*"] = { + -- formatter for any / all file types. + require("formatter.filetypes.any").remove_trailing_whitespace, + }, + }, + }) - -- Keymaps - local wk = require('which-key') - wk.add({ - { "f", ":Format", desc = "[F]ormat" }, - { "F", ":FormateWrite", desc = "[F]ormat write" } - }, - { mode = 'n', silent = true } - ) + -- Keymaps + local wk = require("which-key") + wk.add({ + { "f", ":Format", desc = "[F]ormat" }, + { "F", ":FormateWrite", desc = "[F]ormat write" }, + }, { mode = "n", silent = true }) - local augroup = vim.api.nvim_create_augroup - local autocmd = vim.api.nvim_create_autocmd + local augroup = vim.api.nvim_create_augroup + local autocmd = vim.api.nvim_create_autocmd - augroup("__formatter__", { clear = true }) - autocmd("BufWritePost", { - group = "__formatter__", - command = ":FormatWrite" - }) - end + augroup("__formatter__", { clear = true }) + autocmd("BufWritePost", { + group = "__formatter__", + command = ":FormatWrite", + }) + end, } diff --git a/nvim/m-housh/lua/user/plugin/harpoon.lua b/nvim/m-housh/lua/user/plugin/harpoon.lua index 824f1d9..740057e 100644 --- a/nvim/m-housh/lua/user/plugin/harpoon.lua +++ b/nvim/m-housh/lua/user/plugin/harpoon.lua @@ -1,94 +1,85 @@ return { - "ThePrimeagen/harpoon", - branch = "harpoon2", - dependencies = { - "nvim-lua/plenary.nvim" - }, - config = function() - local harpoon = require('harpoon') - harpoon:setup({ - settings = { - save_on_toggle = true, - sync_on_ui_close = true, - key = function() - return vim.loop.cwd() - end, - } - }) + "ThePrimeagen/harpoon", + branch = "harpoon2", + dependencies = { + "nvim-lua/plenary.nvim", + }, + config = function() + local harpoon = require("harpoon") + harpoon:setup({ + settings = { + save_on_toggle = true, + sync_on_ui_close = true, + key = function() + return vim.loop.cwd() + end, + }, + }) - local conf = require('telescope.config').values - local function toggle_telescope(harpoon_files) - local file_paths = {} - for _, item in ipairs(harpoon_files.items) do - table.insert(file_paths, item.value) - end + local conf = require("telescope.config").values + local function toggle_telescope(harpoon_files) + local file_paths = {} + for _, item in ipairs(harpoon_files.items) do + table.insert(file_paths, item.value) + end - require('telescope.pickers').new({}, { - prompt_title = 'Harpoon', - finder = require('telescope.finders').new_table({ - results = file_paths, - }), - previewer = conf.file_previewer({}), - sorter = conf.generic_sorter({}), - }):find() - end + require("telescope.pickers") + .new({}, { + prompt_title = "Harpoon", + finder = require("telescope.finders").new_table({ + results = file_paths, + }), + previewer = conf.file_previewer({}), + sorter = conf.generic_sorter({}), + }) + :find() + end - -- Keymaps - vim.keymap.set("n", "", - function() toggle_telescope(harpoon:list()) end, - { desc = "Open Harpoon window" } - ) + -- Keymaps + vim.keymap.set("n", "", function() + toggle_telescope(harpoon:list()) + end, { desc = "Open Harpoon window" }) - vim.keymap.set("n", "a", - function() harpoon:list():add() end, - { desc = "[A]dd to harpoon list." } - ) - vim.keymap.set("n", "", - function() harpoon.ui:toggle_quick_menu(harpoon:list()) end, - { desc = "Toggle quick menu." } - ) + vim.keymap.set("n", "a", function() + harpoon:list():add() + end, { desc = "[A]dd to harpoon list." }) + vim.keymap.set("n", "", function() + harpoon.ui:toggle_quick_menu(harpoon:list()) + end, { desc = "Toggle quick menu." }) - -- Buffer key maps. Currently keeping all buffer movements - -- isolated to top left row of keys on keyboard and all begin - -- with the key. + -- Buffer key maps. Currently keeping all buffer movements + -- isolated to top left row of keys on keyboard and all begin + -- with the key. - -- Select buffer numbers. - vim.keymap.set("n", "", - function() harpoon:list():select(1) end, - { desc = "Select first harpoon buffer." } - ) - vim.keymap.set("n", "", - function() harpoon:list():select(2) end, - { desc = "Select second harpoon buffer." } - ) - vim.keymap.set("n", "", - function() harpoon:list():select(3) end, - { desc = "Select third harpoon buffer." } - ) - vim.keymap.set("n", "", - function() harpoon:list():select(3) end, - { desc = "Select third harpoon buffer." } - ) + -- Select buffer numbers. + vim.keymap.set("n", "", function() + harpoon:list():select(1) + end, { desc = "Select first harpoon buffer." }) + vim.keymap.set("n", "", function() + harpoon:list():select(2) + end, { desc = "Select second harpoon buffer." }) + vim.keymap.set("n", "", function() + harpoon:list():select(3) + end, { desc = "Select third harpoon buffer." }) + vim.keymap.set("n", "", function() + harpoon:list():select(4) + end, { desc = "Select fourth harpoon buffer." }) + -- Toggle previous and next buffers. + vim.keymap.set("n", "", function() + harpoon:list():prev() + end, { desc = "[P]revious harpoon buffer." }) + vim.keymap.set("n", "", function() + harpoon:list():next() + end, { desc = "[N]ext harpoon buffer." }) - -- Toggle previous and next buffers. - vim.keymap.set("n", "", - function() harpoon:list():prev() end, - { desc = "[P]revious harpoon buffer." } - ) - vim.keymap.set("n", "", - function() harpoon:list():next() end, - { desc = "[N]ext harpoon buffer." } - ) - - -- Extensions - harpoon:extend({ - UI_CREATE = function(cx) - vim.keymap.set("n", "", - function() harpoon.ui:select_menu_item({ vsplit = true }) end, - { buffer = cx.buffer, desc = "Open in [V]split" } - ) - end - }) - end + -- Extensions + harpoon:extend({ + UI_CREATE = function(cx) + vim.keymap.set("n", "", function() + harpoon.ui:select_menu_item({ vsplit = true }) + end, { buffer = cx.buffer, desc = "Open in [V]split" }) + end, + }) + end, } diff --git a/nvim/m-housh/lua/user/plugin/lsp.lua b/nvim/m-housh/lua/user/plugin/lsp.lua index d6a54be..2ef6815 100755 --- a/nvim/m-housh/lua/user/plugin/lsp.lua +++ b/nvim/m-housh/lua/user/plugin/lsp.lua @@ -1,332 +1,90 @@ return { - { - "williamboman/nvim-lsp-installer", - config = function() - require("nvim-lsp-installer").setup({}) - end - }, - { - "williamboman/mason-lspconfig.nvim", - dependencies = { - "williamboman/mason.nvim", - "onsails/lspkind-nvim", - "famiu/bufdelete.nvim", - "ray-x/lsp_signature.nvim", - "neovim/nvim-lspconfig", - "folke/neodev.nvim", - "mhartington/formatter.nvim", - "ray-x/go.nvim", - }, - opts = { - ensure_installed = { - "bashls", - "clangd", - "dockerls", - "gopls", - "jsonls", - "jedi_language_server", - "lua_ls", - "marksman", - "terraformls", - "ts_ls", - "texlab", - "yamlls", - } - } - }, + "neovim/nvim-lspconfig", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { + "hrsh7th/cmp-nvim-lsp", + { "antosha417/nvim-lsp-file-operations", config = true }, + }, + config = function() + local lspconfig = require("lspconfig") + local cmp_nvim_lsp = require("cmp_nvim_lsp") + local capabilities = cmp_nvim_lsp.default_capabilities() + local opts = { noremap = true, silent = true } + local on_attach = + function(_, bufnr) + opts.buffer = bufnr - { - "neovim/nvim-lspconfig", - event = { "BufReadPost", "BufNewFile" }, - cmd = { "LspInfo", "LspInstall", "LspUninstall", "LspStart", "LspStop", "LspRestart" }, - config = function() - require('neodev').setup() - require("mason").setup() - require("mason-lspconfig").setup() - local lspconfig = require('lspconfig') + opts.desc = "Show line diagnostics" + vim.keymap.set("n", "d", vim.diagnostic.open_float, opts) - lspconfig.bashls.setup {} - lspconfig.clangd.setup {} - lspconfig.dockerls.setup {} - lspconfig.gopls.setup {} - lspconfig.jsonls.setup {} - lspconfig.lua_ls.setup {} - lspconfig.marksman.setup {} - lspconfig.yamlls.setup {} - lspconfig.sourcekit.setup({ - capabilities = { - workspace = { - didChangeWatchedFiles = { - dynamicRegistration = true, - }, - }, - }, - cmd = { "/usr/bin/sourcekit-lsp" } - }) + opts.desc = "Show diagnostics in Telescope" + vim.keymaps.set("n", "d", "Telescope diagnostics bufnr=0", opts) - vim.api.nvim_create_autocmd('LspAttach', { - desc = 'LSP Actions', - callback = function(args) - -- Configure keybindings once we've attached. - local wk = require('which-key') + opts.desc = "Show documentation for what is under cursor" + vim.keymap.set("n", "", vim.lsp.buf.hover, opts) - -- Normal mode keymaps - wk.add({ - { "", vim.lsp.buf.hover, desc = "LSP hover info" }, - { "ca", vim.lsp.buf.code_action, desc = "LSP [C]ode [A]ction" }, - { "gd", vim.lsp.buf.definition, desc = "[G]oto [D]efinition" }, - { "gD", vim.lsp.buf.declaration, desc = "[G]oto [D]eclaration" }, - { "gi", vim.lsp.buf.implementation, desc = "[G]oto [I]mplementation" }, - { "gr", vim.lsp.buf.references, desc = "List [R]eferences" }, - {"gs", vim.lsp.buf.signature_help, desc = "[S]ignature help" }, - { "rn", vim.lsp.buf.rename, desc = "[R]e[N]ame" }, - { "rl", ":LspRestart | :LspStart", desc = "[R]estart or start lsp." }, - { "d", "Telescope diagnostics bufnr=0", desc = "[D]iagnostics" }, - { "[d", vim.diagnostic.goto_prev, desc = "Go to previous diagnostic" }, - { "]d", vim.diagnostic.goto_prev, desc = "Go to next diagnostic" }, - }, { - mode = 'n', - silent = true, - noremap = true - }) + opts.desc = "[G]oto [D]efinition" + vim.keymap.set("n", "gd", "Telescope lsp_definitions trim_text=true", opts) - -- Visual mode keymaps - wk.add({ - { "ca", vim.lsp.buf.code_action, desc = "LSP [C]ode [A]ction" }, - }, - { mode = 'v', silent = true } - ) - end, - }) - end - } + opts.desc = "[G]oto [D]eclaration" + vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) + + opts.desc = "LSP [C]ode [A]ction" + vim.keymap.set("n", "ca", vim.lsp.buf.code_action, opts) + + --opts.desc = "[R]e-[N]ame" + --vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) + + opts.desc = "[R]eload or start LSP" + vim.keymap.set("n", "rl", ":LspRestart | :LspStart", opts) + + opts.desc = "Goto previous diagnostic" + vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) + + opts.desc = "Goto next diagnostic" + vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts) + end, lspconfig["sourcekit"].setup({ + capabilities = capabilities, + on_attach = on_attach, + on_init = function(client) + -- HACK: to fix some issues with LSP + -- more details: https://github.com/neovim/neovim/issues/19237#issuecomment-2237037154 + client.offset_encoding = "utf-8" + end, + }) + + -- nice icons + local signs = { Error = " ", Warn = " ", Hint = "󰠠 ", Info = " " } + for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) + end + + vim.keymap.set("n", "rn", vim.lsp.buf.rename, { desc = "[R]e-[N]ame" }) + end, } --- return { --- { --- "williamboman/nvim-lsp-installer", --- config = function() --- require("nvim-lsp-installer").setup({}) --- end --- }, --- { --- "williamboman/mason-lspconfig.nvim", --- dependencies = { --- "williamboman/mason.nvim", --- "onsails/lspkind-nvim", --- "famiu/bufdelete.nvim", --- "ray-x/lsp_signature.nvim", --- "neovim/nvim-lspconfig", --- "folke/neodev.nvim", --- "mhartington/formatter.nvim", --- "ray-x/go.nvim", --- }, --- opts = { --- ensure_installed = { --- "bashls", --- "clangd", --- "dockerls", --- "gopls", --- "jsonls", --- "jedi_language_server", --- "lua_ls", --- "marksman", --- "terraformls", --- "ts_ls", --- "texlab", --- "yamlls", --- } --- } --- }, --- { --- "neovim/nvim-lspconfig", --- dependencies = { --- "hrsh7th/cmp-nvim-lsp", --- }, --- config = function() --- require('neodev').setup() --- require("mason").setup() --- require("mason-lspconfig").setup() --- local nvim_lsp = require("lspconfig") --- local telescope_builtin = require('telescope.builtin') + -- --- vim.api.nvim_create_autocmd('LspAttach', { --- group = vim.api.nvim_create_augroup('my-lsp-attach', { clear = true }), --- callback = function(event) --- -- Helper function to create a keymap. --- local map = function(keys, func, desc) --- vim.keymap.set('n', keys, func, { buffer = true, desc = 'LSP: ' .. desc }) --- end +-- -- Normal mode keymaps +-- wk.add({ +-- { "", vim.lsp.buf.hover, desc = "LSP hover info" }, +-- { "ca", vim.lsp.buf.code_action, desc = "LSP [C]ode [A]ction" }, +-- { "gi", vim.lsp.buf.implementation, desc = "[G]oto [I]mplementation" }, +-- { "gr", vim.lsp.buf.references, desc = "List [R]eferences" }, +-- { "gs", vim.lsp.buf.signature_help, desc = "[S]ignature help" }, +-- }, { +-- mode = "n", +-- silent = true, +-- noremap = true, +-- }) -- --- -- Mappings. --- -- See `:help vim.lsp.*` for documentation on any of the below functions --- --- map('[d', 'lua vim.lsp.diagnostic.goto_prev()', 'Goto previous') --- map(']d', 'lua vim.lsp.diagnostic.goto_next()', 'Goto next') --- map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') --- map('rn', vim.lsp.buf.rename, '[R]e[n]ame') --- map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') --- map('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') --- map('gi', telescope_builtin.lsp_implementations, '[G]oto, [I]mplementation') --- map('gr', telescope_builtin.lsp_references, '[G]oto [R]eferences') --- map('gt', telescope_builtin.lsp_type_definitions, '[T]ype Definitions') --- map('K', vim.lsp.buf.hover, 'Hover Documentation') --- --- -- -- buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) --- -- buf_set_keymap("n", "wa", --- -- "lua vim.lsp.buf.add_workspace_folder()", opts) --- -- buf_set_keymap("n", "wr", --- -- "lua vim.lsp.buf.remove_workspace_folder()", opts) --- -- buf_set_keymap("n", "wl", --- -- "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))", --- -- opts) --- -- buf_set_keymap("n", "e", "lua vim.lsp.diagnostic.show_line_diagnostics()", opts) --- -- buf_set_keymap("n", "q", "lua vim.lsp.diagnostic.set_loclist()", opts) --- vim.api.nvim_buf_set_option(event.buf, 'omnifunc', 'v:lua.vim.lsp.omnifunc') --- end, --- }) --- --- -- Use a loop to conveniently call 'setup' on multiple servers and --- -- map buffer local keybindings when the language server attaches --- local capabilities = vim.lsp.protocol.make_client_capabilities() --- capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) --- --- local servers = { --- "bashls", --- "clangd", --- "dockerls", --- "gopls", --- "jsonls", --- "jedi_language_server", --- "lua_ls", --- "marksman", --- "sourcekit", --- "terraformls", --- "ts_ls", --- "texlab", --- "yamlls", --- } --- --- for _, lsp in ipairs(servers) do --- nvim_lsp[lsp].setup { --- capabilities = capabilities, --- settings = { --- gopls = { --- experimentalPostfixCompletions = true, --- analyses = { --- unusedparams = true, --- shadow = true --- }, --- staticcheck = true --- }, --- lua_ls = { --- Lua = { --- completion = { --- callSnippet = "Replace" --- }, --- workspace = { checkThirdParty = false }, --- telemetry = { enable = false }, --- } --- }, --- json = { --- format = {enabled = false}, --- schemas = { --- { --- description = "ESLint config", --- fileMatch = {".eslintrc.json", ".eslintrc"}, --- url = "http://json.schemastore.org/eslintrc" --- }, { --- description = "Package config", --- fileMatch = {"package.json"}, --- url = "https://json.schemastore.org/package" --- }, { --- description = "Packer config", --- fileMatch = {"packer.json"}, --- url = "https://json.schemastore.org/packer" --- }, { --- description = "Renovate config", --- fileMatch = { --- "renovate.json", "renovate.json5", --- ".github/renovate.json", ".github/renovate.json5", --- ".renovaterc", ".renovaterc.json" --- }, --- url = "https://docs.renovatebot.com/renovate-schema" --- }, { --- description = "OpenApi config", --- fileMatch = {"*api*.json"}, --- url = "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.1/schema.json" --- } --- } --- }, --- redhat = {telemetry = {enabled = false}}, --- texlab = { --- auxDirectory = ".", --- bibtexFormatter = "texlab", --- build = { --- args = { --- "--keep-intermediates", "--keep-logs", "--synctex", "%f" --- }, --- executable = "tectonic", --- forwardSearchAfter = false, --- onSave = false --- }, --- chktex = {onEdit = false, onOpenAndSave = false}, --- diagnosticsDelay = 300, --- formatterLineLength = 80, --- forwardSearch = {args = {}}, --- latexFormatter = "latexindent", --- latexindent = {modifyLineBreaks = false} --- }, --- yaml = { --- schemaStore = { --- enable = true, --- url = "https://www.schemastore.org/api/json/catalog.json" --- }, --- schemas = { --- kubernetes = "/*.yaml", --- ["http://json.schemastore.org/github-workflow"] = ".github/workflows/*.{yml,yaml}", --- ["http://json.schemastore.org/github-action"] = ".github/action.{yml,yaml}", --- ["http://json.schemastore.org/ansible-stable-2.9"] = "roles/tasks/*.{yml,yaml}", --- ["http://json.schemastore.org/prettierrc"] = ".prettierrc.{yml,yaml}", --- ["http://json.schemastore.org/kustomization"] = "kustomization.{yml,yaml}", --- ["http://json.schemastore.org/ansible-playbook"] = "*play*.{yml,yaml}", --- ["http://json.schemastore.org/chart"] = "Chart.{yml,yaml}", --- ["https://json.schemastore.org/dependabot-v2"] = ".github/dependabot.{yml,yaml}", --- ["https://json.schemastore.org/gitlab-ci"] = "*gitlab-ci*.{yml,yaml}", --- ["https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.1/schema.json"] = "*api*.{yml,yaml}", --- ["https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json"] = "docker-compose.{yml,yaml}", --- ["https://raw.githubusercontent.com/argoproj/argo-workflows/master/api/jsonschema/schema.json"] = "*flow*.{yml,yaml}" --- }, --- format = {enabled = false}, --- validate = false, -- TODO: conflicts between Kubernetes resources and kustomization.yaml --- completion = true, --- hover = true --- } --- }, --- flags = {debounce_text_changes = 150} --- } --- require"lsp_signature".setup({ --- bind = true, -- This is mandatory, otherwise border config won't get registered. --- floating_window = true, -- show hint in a floating window, set to false for virtual text only mode --- doc_lines = 2, -- Set to 0 for not showing doc --- hint_prefix = "🐼 ", --- -- use_lspsaga = false, -- set to true if you want to use lspsaga popup --- handler_opts = { --- border = "shadow" -- double, single, shadow, none --- } --- }) --- end --- --- -- Test source-kit --- require('lspconfig').sourcekit.setup{ --- capabilities = { --- workspace = { --- didChangeWatchedFiles = { --- dynamicRegistration = true --- } --- } --- } --- } --- --- end --- } +-- -- Visual mode keymaps +-- wk.add({ +-- { "ca", vim.lsp.buf.code_action, desc = "LSP [C]ode [A]ction" }, +-- }, { mode = "v", silent = true }) +-- end, +-- }) +-- end, +-- }, +-- } -- } diff --git a/nvim/m-housh/lua/user/plugin/lualine.lua b/nvim/m-housh/lua/user/plugin/lualine.lua index f0889ae..2af188e 100755 --- a/nvim/m-housh/lua/user/plugin/lualine.lua +++ b/nvim/m-housh/lua/user/plugin/lualine.lua @@ -1,145 +1,217 @@ return { - "nvim-lualine/lualine.nvim", - config = function() - local colors = { - red = '#ca1243', - grey = '#a0a1a7', - black = '#383a42', - white = '#f3f3f3', - light_green = '#83a598', - orange = '#fe8019', - green = '#8ec07c', - } + "nvim-lualine/lualine.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + local lualine = require("lualine") - local empty = require('lualine.component'):extend() - function empty:draw(default_highlight) - self.status = '' - self.applied_separator = '' - self:apply_highlights(default_highlight) - self:apply_section_separators() - return self.status - end + local function xcodebuild_device() + if vim.g.xcodebuild_platform == "macOS" then + return " macOS" + end - -- Put proper separators and gaps between components in sections - local function process_sections(sections) - for name, section in pairs(sections) do - local left = name:sub(9, 10) < 'x' - for pos = 1, name ~= 'lualine_z' and #section or #section - 1 do - table.insert(section, pos * 2, { empty, color = { fg = colors.white, bg = colors.white } }) - end - for id, comp in ipairs(section) do - if type(comp) ~= 'table' then - comp = { comp } - section[id] = comp - end - comp.separator = left and { right = '' } or { left = '' } - end - end - return sections - end + if vim.g.xcodebuild_os then + return " " .. vim.g.xcodebuild_device_name .. " (" .. vim.g.xcodebuild_os .. ")" + end - local function search_result() - if vim.v.hlsearch == 0 then - return '' - end - local last_search = vim.fn.getreg '/' - if not last_search or last_search == '' then - return '' - end - local searchcount = vim.fn.searchcount { maxcount = 9999 } - return last_search .. '(' .. searchcount.current .. '/' .. searchcount.total .. ')' - end + return " " .. vim.g.xcodebuild_device_name + end - local function modified() - if vim.bo.modified then - return '+' - elseif vim.bo.modifiable == false or vim.bo.readonly == true then - return '-' - end - return '' - end - - local function xcodebuild_device() - if vim.g.xcodebuild_platform == "macOS" then - return " macOS" - end - - local deviceIcon = "" - if vim.g.xcodebuild_platform:match("watch") then - deviceIcon = "􀟤" - elseif vim.g.xcodebuild_platform:match("tv") then - deviceIcon = "􀡴 " - elseif vim.g.xcodebuild_platform:match("vision") then - deviceIcon = "􁎖 " - end - - if vim.g.xcodebuild_os then - return deviceIcon .. " " .. vim.g.xcodebuild_device_name .. " (" .. vim.g.xcodebuild_os .. ")" - end - - return deviceIcon .. " " .. vim.g.xcodebuild_device_name - end - - - require('lualine').setup { - options = { - theme = 'auto', - component_separators = '', - section_separators = { left = '', right = '' }, - }, - sections = process_sections { - lualine_a = { 'mode' }, - lualine_b = { - 'branch', - 'diff', - { - 'diagnostics', - source = { 'nvim' }, - sections = { 'error' }, - diagnostics_color = { error = { bg = colors.red, fg = colors.white } }, - }, - { - 'diagnostics', - source = { 'nvim' }, - sections = { 'warn' }, - diagnostics_color = { warn = { bg = colors.orange, fg = colors.white } }, - }, - { 'filename', file_status = false, path = 1 }, - { modified, color = { bg = colors.red } }, - { - '%w', - cond = function() - return vim.wo.previewwindow - end, - }, - { - '%r', - cond = function() - return vim.bo.readonly - end, - }, - { - '%q', - cond = function() - return vim.bo.buftype == 'quickfix' - end, - }, - }, - lualine_c = {}, - lualine_x = { - { "' ' .. vim.g.xcodebuild_last_status", color = { fg = "Gray" } }, - { "'󰙨 ' .. vim.g.xcodebuild_test_plan", color = { fg = "#a6e3a1", bg = "#161622" } }, - { xcodebuild_device, color = { fg = "#f9e2af", bg = "#161622" } }, - }, - lualine_y = { search_result, 'filetype' }, - lualine_z = { '%l:%c', '%p%%/%L' }, - }, - inactive_sections = { - lualine_c = { '%f %y %m' }, - lualine_x = {}, - }, - tabline = {}, - extensions = {"nvim-tree"} - } - end + lualine.setup({ + options = { + globalstatus = true, + theme = "auto", + symbols = { + alternate_file = "#", + directory = "", + readonly = "", + unnamed = "[No Name]", + newfile = "[New]", + }, + disabled_buftypes = { "quickfix", "prompt" }, + component_separators = "", + section_separators = { left = "", right = "" }, + }, + sections = { + lualine_a = { + -- { "mode" }, + { "filename" }, + }, + lualine_b = { + { "diagnostics" }, + { "diff" }, + { + "searchcount", + maxcount = 999, + timeout = 500, + }, + }, + lualine_c = {}, + lualine_x = { + { "' ' .. vim.g.xcodebuild_last_status", color = { fg = "#a6e3a1" } }, + -- { "'󰙨 ' .. vim.g.xcodebuild_test_plan", color = { fg = "#a6e3a1", bg = "#161622" } }, + { xcodebuild_device, color = { fg = "#f9e2af", bg = "#161622" } }, + }, + lualine_y = { + { "branch" }, + }, + lualine_z = { + { "location" }, + }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { "filename" }, + lualine_x = {}, + lualine_y = {}, + lualine_z = {}, + }, + extensions = { "nvim-dap-ui", "quickfix", "trouble", "nvim-tree", "lazy", "mason" }, + }) + end, } +-- return { +-- "nvim-lualine/lualine.nvim", +-- config = function() +-- local colors = { +-- red = '#ca1243', +-- grey = '#a0a1a7', +-- black = '#383a42', +-- white = '#f3f3f3', +-- light_green = '#83a598', +-- orange = '#fe8019', +-- green = '#8ec07c', +-- } +-- +-- local empty = require('lualine.component'):extend() +-- function empty:draw(default_highlight) +-- self.status = '' +-- self.applied_separator = '' +-- self:apply_highlights(default_highlight) +-- self:apply_section_separators() +-- return self.status +-- end +-- +-- -- Put proper separators and gaps between components in sections +-- local function process_sections(sections) +-- for name, section in pairs(sections) do +-- local left = name:sub(9, 10) < 'x' +-- for pos = 1, name ~= 'lualine_z' and #section or #section - 1 do +-- table.insert(section, pos * 2, { empty, color = { fg = colors.white, bg = colors.white } }) +-- end +-- for id, comp in ipairs(section) do +-- if type(comp) ~= 'table' then +-- comp = { comp } +-- section[id] = comp +-- end +-- comp.separator = left and { right = '' } or { left = '' } +-- end +-- end +-- return sections +-- end +-- +-- local function search_result() +-- if vim.v.hlsearch == 0 then +-- return '' +-- end +-- local last_search = vim.fn.getreg '/' +-- if not last_search or last_search == '' then +-- return '' +-- end +-- local searchcount = vim.fn.searchcount { maxcount = 9999 } +-- return last_search .. '(' .. searchcount.current .. '/' .. searchcount.total .. ')' +-- end +-- +-- local function modified() +-- if vim.bo.modified then +-- return '+' +-- elseif vim.bo.modifiable == false or vim.bo.readonly == true then +-- return '-' +-- end +-- return '' +-- end +-- +-- local function xcodebuild_device() +-- if vim.g.xcodebuild_platform == "macOS" then +-- return " macOS" +-- end +-- +-- local deviceIcon = "" +-- if vim.g.xcodebuild_platform:match("watch") then +-- deviceIcon = "􀟤" +-- elseif vim.g.xcodebuild_platform:match("tv") then +-- deviceIcon = "􀡴 " +-- elseif vim.g.xcodebuild_platform:match("vision") then +-- deviceIcon = "􁎖 " +-- end +-- +-- if vim.g.xcodebuild_os then +-- return deviceIcon .. " " .. vim.g.xcodebuild_device_name .. " (" .. vim.g.xcodebuild_os .. ")" +-- end +-- +-- return deviceIcon .. " " .. vim.g.xcodebuild_device_name +-- end +-- +-- +-- require('lualine').setup { +-- options = { +-- theme = 'auto', +-- component_separators = '', +-- section_separators = { left = '', right = '' }, +-- }, +-- sections = process_sections { +-- lualine_a = { 'mode' }, +-- lualine_b = { +-- 'branch', +-- 'diff', +-- { +-- 'diagnostics', +-- source = { 'nvim' }, +-- sections = { 'error' }, +-- diagnostics_color = { error = { bg = colors.red, fg = colors.white } }, +-- }, +-- { +-- 'diagnostics', +-- source = { 'nvim' }, +-- sections = { 'warn' }, +-- diagnostics_color = { warn = { bg = colors.orange, fg = colors.white } }, +-- }, +-- { 'filename', file_status = false, path = 1 }, +-- { modified, color = { bg = colors.red } }, +-- { +-- '%w', +-- cond = function() +-- return vim.wo.previewwindow +-- end, +-- }, +-- { +-- '%r', +-- cond = function() +-- return vim.bo.readonly +-- end, +-- }, +-- { +-- '%q', +-- cond = function() +-- return vim.bo.buftype == 'quickfix' +-- end, +-- }, +-- }, +-- lualine_c = {}, +-- lualine_x = { +-- { "' ' .. vim.g.xcodebuild_last_status", color = { fg = "Gray" } }, +-- { "'󰙨 ' .. vim.g.xcodebuild_test_plan", color = { fg = "#a6e3a1", bg = "#161622" } }, +-- { xcodebuild_device, color = { fg = "#f9e2af", bg = "#161622" } }, +-- }, +-- lualine_y = { search_result, 'filetype' }, +-- lualine_z = { '%l:%c', '%p%%/%L' }, +-- }, +-- inactive_sections = { +-- lualine_c = { '%f %y %m' }, +-- lualine_x = {}, +-- }, +-- tabline = {}, +-- extensions = {"nvim-tree"} +-- } +-- end +-- } diff --git a/nvim/m-housh/lua/user/plugin/nvim-dap.lua b/nvim/m-housh/lua/user/plugin/nvim-dap.lua new file mode 100644 index 0000000..0aed3df --- /dev/null +++ b/nvim/m-housh/lua/user/plugin/nvim-dap.lua @@ -0,0 +1,70 @@ +local function setupListeners() + local dap = require("dap") + local areSet = false + + dap.listeners.after["event_initialized"]["me"] = function() + if not areSet then + areSet = true + vim.keymap.set("n", "dc", dap.continue, { desc = "Continue", noremap = true }) + vim.keymap.set("n", "dC", dap.run_to_cursor, { desc = "Run To Cursor" }) + vim.keymap.set("n", "ds", dap.step_over, { desc = "Step Over" }) + vim.keymap.set("n", "di", dap.step_into, { desc = "Step Into" }) + vim.keymap.set("n", "do", dap.step_out, { desc = "Step Out" }) + vim.keymap.set({ "n", "v" }, "dh", require("dap.ui.widgets").hover, { desc = "Hover" }) + vim.keymap.set({ "n", "v" }, "de", require("dapui").eval, { desc = "Eval" }) + end + end + + dap.listeners.after["event_terminated"]["me"] = function() + if areSet then + areSet = false + vim.keymap.del("n", "dc") + vim.keymap.del("n", "dC") + vim.keymap.del("n", "ds") + vim.keymap.del("n", "di") + vim.keymap.del("n", "do") + vim.keymap.del({ "n", "v" }, "dh") + vim.keymap.del({ "n", "v" }, "de") + end + end +end + +return { + "mfussenegger/nvim-dap", + dependencies = { + "wojciech-kulik/xcodebuild.nvim", + }, + config = function() + local xcodebuild = require("xcodebuild.integrations.dap") + + -- TODO: make sure to set path to your codelldb + local codelldbPath = os.getenv("HOME") .. "/tools/codelldb-aarch64-darwin/extension/adapter/codelldb" + xcodebuild.setup(codelldbPath) + + local define = vim.fn.sign_define + define("DapBreakpoint", { text = "", texthl = "DiagnosticError", linehl = "", numhl = "" }) + define("DapBreakpointRejected", { text = "", texthl = "DiagnosticError", linehl = "", numhl = "" }) + define("DapStopped", { text = "", texthl = "DiagnosticOk", linehl = "", numhl = "" }) + define("DapLogPoint", { text = "", texthl = "DiagnosticInfo", linehl = "", numhl = "" }) + define("DapLogPoint", { text = "", texthl = "DiagnosticInfo", linehl = "", numhl = "" }) + + setupListeners() + + --when breakpoint is hit, it sets the focus to the buffer with the breakpoint + require("dap").defaults.fallback.switchbuf = "usetab,uselast" + + --stylua: ignore start + vim.keymap.set("n", "dd", xcodebuild.build_and_debug, { desc = "Build & Debug" }) + vim.keymap.set("n", "dr", xcodebuild.debug_without_build, { desc = "Debug Without Building" }) + vim.keymap.set("n", "dt", xcodebuild.debug_tests, { desc = "Debug Tests" }) + vim.keymap.set("n", "dT", xcodebuild.debug_class_tests, { desc = "Debug Class Tests" }) + vim.keymap.set("n", "b", xcodebuild.toggle_breakpoint, { desc = "Toggle Breakpoint" }) + vim.keymap.set("n", "B", xcodebuild.toggle_message_breakpoint, { desc = "Toggle Message Breakpoint" }) + --stylua: ignore end + + vim.keymap.set("n", "dx", function() + xcodebuild.terminate_session() + require("dap").listeners.after["event_terminated"]["me"]() + end, { desc = "Terminate debugger" }) + end, +} diff --git a/nvim/m-housh/lua/user/plugin/nvim-dapui.lua b/nvim/m-housh/lua/user/plugin/nvim-dapui.lua new file mode 100644 index 0000000..dd905be --- /dev/null +++ b/nvim/m-housh/lua/user/plugin/nvim-dapui.lua @@ -0,0 +1,87 @@ +return { + "rcarriga/nvim-dap-ui", + dependencies = { + "mfussenegger/nvim-dap", + "nvim-neotest/nvim-nio", + }, + lazy = true, + config = function() + require("dapui").setup({ + controls = { + element = "repl", + enabled = true, + icons = { + disconnect = "", + run_last = "", + terminate = "⏹︎", + pause = "⏸︎", + play = "", + step_into = "󰆹", + step_out = "󰆸", + step_over = "", + step_back = "", + }, + }, + floating = { + border = "single", + mappings = { + close = { "q", "" }, + }, + }, + icons = { + collapsed = "", + expanded = "", + current_frame = "", + }, + layouts = { + { + elements = { + { id = "stacks", size = 0.25 }, + { id = "scopes", size = 0.25 }, + { id = "breakpoints", size = 0.25 }, + { id = "watches", size = 0.25 }, + }, + position = "left", + size = 40, + }, + { + elements = { + { id = "repl", size = 0.4 }, + { id = "console", size = 0.6 }, + }, + position = "bottom", + size = 10, + }, + }, + }) + + local dap, dapui = require("dap"), require("dapui") + local group = vim.api.nvim_create_augroup("dapui_config", { clear = true }) + + -- hide ~ in DAPUI + vim.api.nvim_create_autocmd("BufWinEnter", { + group = group, + pattern = "DAP*", + callback = function() + vim.wo.fillchars = "eob: " + end, + }) + vim.api.nvim_create_autocmd("BufWinEnter", { + group = group, + pattern = "\\[dap\\-repl\\]", + callback = function() + vim.wo.fillchars = "eob: " + end, + }) + + 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 + end, +} diff --git a/nvim/m-housh/lua/user/plugin/telescope.lua b/nvim/m-housh/lua/user/plugin/telescope.lua index ce6e126..00d8742 100755 --- a/nvim/m-housh/lua/user/plugin/telescope.lua +++ b/nvim/m-housh/lua/user/plugin/telescope.lua @@ -1,75 +1,78 @@ return { - 'nvim-telescope/telescope.nvim', - branch = '0.1.x', - dependencies = { - 'nvim-lua/plenary.nvim' - }, - lazy = true, - config = function() - local actions = require('telescope.actions') - local builtin = require('telescope.builtin') + "nvim-telescope/telescope.nvim", + branch = "0.1.x", + dependencies = { + "nvim-lua/plenary.nvim", + }, + lazy = true, + config = function() + local actions = require("telescope.actions") + local builtin = require("telescope.builtin") - require('telescope').setup({ - defaults = { - file_ignore_patterns = {"node_modules", "%.jpg", "%.png", ".swiftpm"}, - vimgrep_arguments = { - 'rg', - '--follow', - '--color=never', - '--no-heading', - '--with-filename', - '--line-number', - '--column', - '--smart-case' - }, - mappings = { - i = { - -- Close on first esc instead of gonig to normal mode - [""] = actions.close, - [""] = actions.send_selected_to_qflist, - [""] = actions.send_to_qflist, - [""] = actions.toggle_selection + actions.move_selection_next, - [""] = actions.toggle_selection + actions.move_selection_previous, - }, - n = { - [""] = actions.toggle_selection + actions.move_selection_next, - [""] = actions.toggle_selection + actions.move_selection_previous, - [""] = actions.send_selected_to_qflist, - [""] = actions.send_to_qflist, - }, - }, - prompt_prefix = " ", - selection_caret = " ", - entry_prefix = " ", - initial_mode = "insert", - selection_strategy = "reset", - sorting_strategy = "descending", - layout_strategy = "flex", - layout_config = { - width = 0.75, - prompt_position = "bottom", - preview_cutoff = 120, - horizontal = { mirror = false }, - vertical = { mirror = true }, - }, - file_sorter = require'telescope.sorters'.get_fuzzy_file, - generic_sorter = require'telescope.sorters'.get_generic_fuzzy_sorter, - -- path_display = true, -- strange behaviour not showing the files in result window - winblend = 0, - border = {}, - borderchars = { '─', '│', '─', '│', '╭', '╮', '╯', '╰' }, - color_devicons = true, - use_less = true, - set_env = { ['COLORTERM'] = 'truecolor' }, -- default = nil, - file_previewer = require'telescope.previewers'.vim_buffer_cat.new, - grep_previewer = require'telescope.previewers'.vim_buffer_vimgrep.new, - qflist_previewer = require'telescope.previewers'.vim_buffer_qflist.new, + require("telescope").setup({ + ensure_installed = { + "swift", + }, + defaults = { + file_ignore_patterns = { "node_modules", "%.jpg", "%.png", ".swiftpm" }, + vimgrep_arguments = { + "rg", + "--follow", + "--color=never", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + "--smart-case", + }, + mappings = { + i = { + -- Close on first esc instead of gonig to normal mode + [""] = actions.close, + [""] = actions.send_selected_to_qflist, + [""] = actions.send_to_qflist, + [""] = actions.toggle_selection + actions.move_selection_next, + [""] = actions.toggle_selection + actions.move_selection_previous, + }, + n = { + [""] = actions.toggle_selection + actions.move_selection_next, + [""] = actions.toggle_selection + actions.move_selection_previous, + [""] = actions.send_selected_to_qflist, + [""] = actions.send_to_qflist, + }, + }, + prompt_prefix = " ", + selection_caret = " ", + entry_prefix = " ", + initial_mode = "insert", + selection_strategy = "reset", + sorting_strategy = "descending", + layout_strategy = "flex", + layout_config = { + width = 0.75, + prompt_position = "bottom", + preview_cutoff = 120, + horizontal = { mirror = false }, + vertical = { mirror = true }, + }, + file_sorter = require("telescope.sorters").get_fuzzy_file, + generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter, + -- path_display = true, -- strange behaviour not showing the files in result window + winblend = 0, + border = {}, + borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, + color_devicons = true, + use_less = true, + set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil, + file_previewer = require("telescope.previewers").vim_buffer_cat.new, + grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new, + qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new, - -- Developer configurations: Not meant for general override - buffer_previewer_maker = require'telescope.previewers'.buffer_previewer_maker - } - }) + -- Developer configurations: Not meant for general override + buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker, + }, + }) - vim.keymap.set("n", "", builtin.jumplist, { silent = true, noremap = true, desc = "Open [J]ump List."}) - end + vim.keymap.set("n", "", builtin.jumplist, { silent = true, noremap = true, desc = "Open [J]ump List." }) + end, } diff --git a/nvim/m-housh/lua/user/plugin/trouble.lua b/nvim/m-housh/lua/user/plugin/trouble.lua index 8becc99..7099da2 100644 --- a/nvim/m-housh/lua/user/plugin/trouble.lua +++ b/nvim/m-housh/lua/user/plugin/trouble.lua @@ -1,24 +1,44 @@ return { - "folke/trouble.nvim", - dependencies = { "nvim-tree/nvim-web-devicons" }, - event = { "BufReadPre", "BufNewFile" }, - keys = { - { "tt", "Trouble quickfix toggle", { desc = "Open a quickfix" } }, - }, + "folke/trouble.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + event = { "BufReadPre", "BufNewFile" }, + keys = { + { "tt", "Trouble quickfix toggle", { desc = "Open a quickfix" } }, + }, - opts = {}, - config = function() - require("trouble").setup({ - auto_open = false, - auto_close = false, - auto_preview = true, - auto_jump = false, - mode = "quickfix", - severity = vim.diagnostic.severity.ERROR, - cycle_results = false, - }) - -- Jump to diagnostic issues across the whole project. - vim.keymap.set("n", "", "silent cc | silent cnzz", { desc = "Jump to next issue" }) - vim.keymap.set("n", "", "silent cc | silent cpzz", { desc = "Jump to previous issue" }) - end, + opts = {}, + config = function() + require("trouble").setup({ + auto_open = false, + auto_close = false, + auto_preview = true, + auto_jump = false, + mode = "quickfix", + severity = vim.diagnostic.severity.ERROR, + cycle_results = false, + }) + vim.api.nvim_create_autocmd("User", { + pattern = { "XcodebuildBuildFinished", "XcodebuildTestsFinished" }, + callback = function(event) + if event.data.cancelled then + return + end + + if event.data.success then + require("trouble").close() + elseif not event.data.failedCount or event.data.failedCount > 0 then + if next(vim.fn.getqflist()) then + require("trouble").open("quickfix") + else + require("trouble").close() + end + + require("trouble").refresh() + end + end, + }) + -- Jump to diagnostic issues across the whole project. + vim.keymap.set("n", "", "silent cc | silent cnzz", { desc = "Jump to next issue" }) + vim.keymap.set("n", "", "silent cc | silent cpzz", { desc = "Jump to previous issue" }) + end, } diff --git a/nvim/m-housh/lua/user/plugin/xcodebuild.lua b/nvim/m-housh/lua/user/plugin/xcodebuild.lua index ab3de1d..1caabf6 100644 --- a/nvim/m-housh/lua/user/plugin/xcodebuild.lua +++ b/nvim/m-housh/lua/user/plugin/xcodebuild.lua @@ -1,20 +1,57 @@ -return { - "wojciech-kulik/xcodebuild.nvim", - dependencies = { - "nvim-telescope/telescope.nvim", - "MunifTanjim/nui.nvim", - "nvim-neo-tree/neo-tree.nvim", -- (optional) to manage project files - "stevearc/oil.nvim", -- (optional) to manage project files - "nvim-treesitter/nvim-treesitter", -- (optional) for Quick tests support (required Swift parser) - }, - config = function() - require("xcodebuild").setup({ - -- put some options here or leave it empty to use default settings - code_coverage = { - enabled = true - } - }) +local progress_handle +return { + "wojciech-kulik/xcodebuild.nvim", + dependencies = { + "nvim-telescope/telescope.nvim", + "MunifTanjim/nui.nvim", + }, + config = function() + require("xcodebuild").setup({ + show_build_progress_bar = false, + logs = { + auto_open_on_success_tests = false, + auto_open_on_failed_tests = false, + auto_open_on_success_build = false, + auto_open_on_failed_build = false, + auto_focus = false, + auto_close_on_app_launch = true, + only_summary = true, + notify = function(message, severity) + local fidget = require("fidget") + if progress_handle then + progress_handle.message = message + if not message:find("Loading") then + progress_handle:finish() + progress_handle = nil + if vim.trim(message) ~= "" then + fidget.notify(message, severity) + end + end + else + fidget.notify(message, severity) + end + end, + notify_progress = function(message) + local progress = require("fidget.progress") + + if progress_handle then + progress_handle.title = "" + progress_handle.message = message + else + progress_handle = progress.handle.create({ + message = message, + lsp_client = { name = "xcodebuild.nvim" }, + }) + end + end, + }, + code_coverage = { + enabled = true, + }, + }) + + -- stylua: ignore start vim.keymap.set("n", "X", "XcodebuildPicker", { desc = "Show Xcodebuild Actions" }) vim.keymap.set("n", "xf", "XcodebuildProjectManager", { desc = "Show Project Manager Actions" }) @@ -24,8 +61,7 @@ return { vim.keymap.set("n", "xt", "XcodebuildTest", { desc = "Run Tests" }) vim.keymap.set("v", "xt", "XcodebuildTestSelected", { desc = "Run Selected Tests" }) - vim.keymap.set("n", "xT", "XcodebuildTestClass", { desc = "Run Current Test Class" }) - vim.keymap.set("n", "x.", "XcodebuildTestRepeat", { desc = "Repeat Last Test Run" }) + vim.keymap.set("n", "xT", "XcodebuildTestClass", { desc = "Run This Test Class" }) vim.keymap.set("n", "xl", "XcodebuildToggleLogs", { desc = "Toggle Xcodebuild Logs" }) vim.keymap.set("n", "xc", "XcodebuildToggleCodeCoverage", { desc = "Toggle Code Coverage" }) @@ -39,5 +75,48 @@ return { vim.keymap.set("n", "xx", "XcodebuildQuickfixLine", { desc = "Quickfix Line" }) vim.keymap.set("n", "xa", "XcodebuildCodeActions", { desc = "Show Code Actions" }) - end, + end, } +-- return { +-- "wojciech-kulik/xcodebuild.nvim", +-- dependencies = { +-- "nvim-telescope/telescope.nvim", +-- "MunifTanjim/nui.nvim", +-- "nvim-neo-tree/neo-tree.nvim", -- (optional) to manage project files +-- "stevearc/oil.nvim", -- (optional) to manage project files +-- "nvim-treesitter/nvim-treesitter", -- (optional) for Quick tests support (required Swift parser) +-- }, +-- config = function() +-- require("xcodebuild").setup({ +-- -- put some options here or leave it empty to use default settings +-- code_coverage = { +-- enabled = true +-- } +-- }) +-- +-- vim.keymap.set("n", "X", "XcodebuildPicker", { desc = "Show Xcodebuild Actions" }) +-- vim.keymap.set("n", "xf", "XcodebuildProjectManager", { desc = "Show Project Manager Actions" }) +-- +-- vim.keymap.set("n", "xb", "XcodebuildBuild", { desc = "Build Project" }) +-- vim.keymap.set("n", "xB", "XcodebuildBuildForTesting", { desc = "Build For Testing" }) +-- vim.keymap.set("n", "xr", "XcodebuildBuildRun", { desc = "Build & Run Project" }) +-- +-- vim.keymap.set("n", "xt", "XcodebuildTest", { desc = "Run Tests" }) +-- vim.keymap.set("v", "xt", "XcodebuildTestSelected", { desc = "Run Selected Tests" }) +-- vim.keymap.set("n", "xT", "XcodebuildTestClass", { desc = "Run Current Test Class" }) +-- vim.keymap.set("n", "x.", "XcodebuildTestRepeat", { desc = "Repeat Last Test Run" }) +-- +-- vim.keymap.set("n", "xl", "XcodebuildToggleLogs", { desc = "Toggle Xcodebuild Logs" }) +-- vim.keymap.set("n", "xc", "XcodebuildToggleCodeCoverage", { desc = "Toggle Code Coverage" }) +-- vim.keymap.set("n", "xC", "XcodebuildShowCodeCoverageReport", { desc = "Show Code Coverage Report" }) +-- vim.keymap.set("n", "xe", "XcodebuildTestExplorerToggle", { desc = "Toggle Test Explorer" }) +-- vim.keymap.set("n", "xs", "XcodebuildFailingSnapshots", { desc = "Show Failing Snapshots" }) +-- +-- vim.keymap.set("n", "xd", "XcodebuildSelectDevice", { desc = "Select Device" }) +-- vim.keymap.set("n", "xp", "XcodebuildSelectTestPlan", { desc = "Select Test Plan" }) +-- vim.keymap.set("n", "xq", "Telescope quickfix", { desc = "Show QuickFix List" }) +-- +-- vim.keymap.set("n", "xx", "XcodebuildQuickfixLine", { desc = "Quickfix Line" }) +-- vim.keymap.set("n", "xa", "XcodebuildCodeActions", { desc = "Show Code Actions" }) +-- end, +-- }