diff --git a/nvim/m-housh/lua/user/plugin/cmp.lua b/nvim/m-housh/lua/user/plugin/cmp.lua index acce32b..f228f41 100755 --- a/nvim/m-housh/lua/user/plugin/cmp.lua +++ b/nvim/m-housh/lua/user/plugin/cmp.lua @@ -12,10 +12,10 @@ return { "f3fora/cmp-spell", "hrsh7th/cmp-calc", "hrsh7th/cmp-emoji", - --"L3MON4D3/LuaSnip", - + "L3MON4D3/LuaSnip", -- Adds a number of user-friendly snippets 'rafamadriz/friendly-snippets', + "onsails/lspkind.nvim", -- vs-code like pictograms }, event = { 'BufReadPre', 'BufNewFile' }, config = function() @@ -24,24 +24,13 @@ return { local lspkind = require("lspkind") local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) - --local luasnip = require('luasnip') - - local has_words_before = function() - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 - and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub( - col, col):match("%s") == nil - end - - local feedkey = function(key, mode) - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), - mode, true) - end - + local luasnip = require('luasnip') require('lspconfig').sourcekit.setup { capabilities = capabilities } + require("luasnip.loaders.from_vscode").lazy_load() + lspkind.init({ symbol_map = { @@ -74,84 +63,55 @@ return { } }) - -- Configure nvim-cmp. - --require('luasnip.loaders.from_vscode').lazy_load() - --luasnip.config.setup {} - cmp.setup({ - formatting = { - format = lspkind.cmp_format { - with_text = false, - maxwidth = 50, - menu = { - buffer = "BUF", - nvim_lsp = "LSP", - path = "PATH", - vsnip = "SNIP", - calc = "CALC", - spell = "SPELL", - emoji = "EMOJI" - } - } - }, - experimental = {native_menu = false, ghost_text = false}, - snippet = { - expand = function(args) - vim.fn["vsnip#anonymous"](args.body) - --luasnip.lsp_expand(args.body) - --require('luasnip').lsp_expand(args.body) + 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 - }, - mapping = { - [""] = cmp.mapping.select_prev_item(), - [""] = cmp.mapping.select_next_item(), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.abort(), - [""] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = true - }, - -- Accept ([y]es) the completions. - ['"] = cmp.mapping(function(fallback) --- if cmp.visible() then --- cmp.select_next_item() --- -- elseif luasnip.expandable() then --- -- luasnip.expand() --- -- elseif luasnip.expand_or_jumpable() then --- -- luasnip.expand_or_jump() --- elseif has_words_before() then --- cmp.complete() --- else --- fallback() --- end --- end, {"i", "s"}), - [""] = cmp.mapping(function() - if cmp.visible() then - cmp.select_prev_item() --- elseif vim.fn["vsnip#jumpable"](-1) == 1 then --- feedkey("(vsnip-jump-prev)", "") - end - end, {"i", "s"}) - }, - sources = { - {name = "nvim_lsp"}, - {name = "buffer", keyword_length = 5}, - {name = 'luasnip', option = { show_autosnippets = true } }, - {name = "calc"}, - {name = "emoji"}, - {name = "spell"}, - {name = "path"} - } + 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 = "...", + }), + }, }) - - -- Use buffer source for `/`. - cmp.setup.cmdline("/", {sources = {{name = "buffer"}}}) - - -- Use cmdline & path source for ':'. - cmp.setup.cmdline(":", { - sources = cmp.config.sources({{name = "path"}}, {{name = "cmdline"}}) - }) - end - } + end, +} diff --git a/nvim/m-housh/lua/user/plugin/lsp.lua b/nvim/m-housh/lua/user/plugin/lsp.lua index a243531..d6a54be 100755 --- a/nvim/m-housh/lua/user/plugin/lsp.lua +++ b/nvim/m-housh/lua/user/plugin/lsp.lua @@ -70,14 +70,18 @@ return { -- Configure keybindings once we've attached. local wk = require('which-key') + -- 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" }, + { "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" }, }, { @@ -85,6 +89,13 @@ return { silent = true, noremap = true }) + + -- 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 a48bf77..f0889ae 100755 --- a/nvim/m-housh/lua/user/plugin/lualine.lua +++ b/nvim/m-housh/lua/user/plugin/lualine.lua @@ -59,6 +59,28 @@ return { 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', @@ -104,7 +126,11 @@ return { }, }, lualine_c = {}, - lualine_x = {}, + 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' }, }, diff --git a/nvim/m-housh/lua/user/plugin/nvim-lint.lua b/nvim/m-housh/lua/user/plugin/nvim-lint.lua index d5b60e0..83867aa 100644 --- a/nvim/m-housh/lua/user/plugin/nvim-lint.lua +++ b/nvim/m-housh/lua/user/plugin/nvim-lint.lua @@ -19,6 +19,6 @@ return { vim.keymap.set("n", "ml", function() require("lint").try_lint() - end, { desc = "Lint file" }) + end, { desc = "[L]int file" }) end, } diff --git a/nvim/m-housh/lua/user/plugin/todo-comments.lua b/nvim/m-housh/lua/user/plugin/todo-comments.lua index 051062d..b333c9a 100644 --- a/nvim/m-housh/lua/user/plugin/todo-comments.lua +++ b/nvim/m-housh/lua/user/plugin/todo-comments.lua @@ -1,5 +1,15 @@ return { "folke/todo-comments.nvim", dependencies = { "nvim-lua/plenary.nvim" }, - opts = { } + opts = { }, + config = function() + require('todo-comments').setup({}) + + vim.keymap.set('n', 'tq', 'TodoQuickFix', + { desc = "[T]odo [Q]uick fix list." } + ) + vim.keymap.set('n', 't', 'TodoTelescope', + { desc = "[T]odo [Q]uick fix list." } + ) + end, } diff --git a/nvim/m-housh/lua/user/plugin/trouble.lua b/nvim/m-housh/lua/user/plugin/trouble.lua new file mode 100644 index 0000000..8becc99 --- /dev/null +++ b/nvim/m-housh/lua/user/plugin/trouble.lua @@ -0,0 +1,24 @@ +return { + "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, +} diff --git a/nvim/m-housh/lua/user/plugins.lua b/nvim/m-housh/lua/user/plugins.lua index b0b50e9..8242455 100755 --- a/nvim/m-housh/lua/user/plugins.lua +++ b/nvim/m-housh/lua/user/plugins.lua @@ -17,28 +17,9 @@ require("lazy").setup({ path = '~/LocalProjects/plugins', fallback = true }, - - -- Theme -- - { import = 'user.plugin.theme' }, - - -- Completions -- - { import = 'user.plugin.cmp' }, - - -- Git -- - { import = 'user.plugin.lazygit' }, - - -- Navigation -- - { import = 'user.plugin.neo-tree' }, - { import = 'user.plugin.telescope' }, - { import = 'user.plugin.harpoon' }, - - -- Utilities -- - { import = 'user.plugin.comment' }, - { import = 'user.plugin.noice' }, - { import = 'user.plugin.swift' }, - { import = 'user.plugin.toggleterm' }, - { import = 'user.plugin.which-key' }, - { import = 'user.plugin.wrapping' }, + -- Import all the plugin configs in the 'plugin' directory + { import = 'user.plugin' }, + -- Plugins that don't have a configuration file. { "folke/zen-mode.nvim", opts = { } @@ -51,7 +32,6 @@ require("lazy").setup({ "NMAC427/guess-indent.nvim", opts = { } }, - { import = 'user.plugin.todo-comments' }, { "NoahTheDuke/vim-just", ft = { "just" } }, { 'chipsenkbeil/distant.nvim', @@ -63,14 +43,15 @@ require("lazy").setup({ -- LSP, formatting, etc. -- { 'folke/neodev.nvim', opts = {} }, - { import = 'user.plugin.lsp' }, - { import = 'user.plugin.xcodebuild' }, - { import = 'user.plugin.lualine' }, - { import = 'user.plugin.treesitter' }, - { import = 'user.plugin.formatter' }, - { import = 'user.plugin.go' }, - { import = 'user.plugin.nvim-lint' }, - --{'fladson/vim-kitty', lazy=true, }, - +}, { + checker = { + enabled = true, + notify = false + }, + change_detection = { + notify = false + } }) + +vim.keymap.set("n", "ll", "Lazy", { desc = "Open [L]azy" })