diff --git a/init.lua b/init.lua index b05f2bf..67b166b 100644 --- a/init.lua +++ b/init.lua @@ -13,6 +13,13 @@ P = function(v) return v end +function TableConcat(t1, t2) + for i=1,#t2 do + t1[#t1+1] = t2[i] + end + return t1 +end + -- [[ Install `lazy.nvim` plugin manager ]] -- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' diff --git a/lua/plugins/ai.lua b/lua/plugins/ai.lua deleted file mode 100644 index fdb524f..0000000 --- a/lua/plugins/ai.lua +++ /dev/null @@ -1,58 +0,0 @@ -local file = vim.fn.glob '~/projects/cdy-nvim' -if file ~= '' then - return { - { - 'projects/cdy-nvim', - dir = '~/projects/cdy-nvim', - cmd = { 'CodyChat', 'CodyAsk', 'CodySetModel', 'CodyToggleFileContext', 'CodyToggleRepoContext', 'CodyNew' }, - dependencies = { - 'MunifTanjim/nui.nvim', - 'nvim-lua/plenary.nvim', - }, - keys = { - { 'cc', 'CodyChat', desc = 'Open cody chat' }, - { 'cn', 'CodyNew', desc = 'Start new cody chat' }, - }, - dev = true, - opts = { - include_file = true, - include_repo = true, - }, - }, - } -else - return { - { - 'olimorris/codecompanion.nvim', - lazy = false, - opts = { - strategies = { - chat = { - adapter = 'anthropic', - }, - inline = { - adapter = 'anthropic', - }, - }, - }, - dependencies = { - 'nvim-lua/plenary.nvim', - 'nvim-treesitter/nvim-treesitter', - }, - }, - -- { - -- 'pasky/claude.vim', - -- lazy = false, - -- config = function() - -- local api_key = os.getenv 'ANTHROPIC_API_KEY' - -- vim.g.claude_api_key = api_key - -- vim.cmd [[ - -- let g:claude_map_implement = "ci" - -- let g:claude_map_open_chat = "cc" - -- let g:claude_map_send_chat_message = "" - -- let g:claude_map_cancel_response = "cx" - -- ]] - -- end, - -- }, - } -end diff --git a/lua/plugins/codecompanion.lua b/lua/plugins/ai/codecompanion.lua similarity index 62% rename from lua/plugins/codecompanion.lua rename to lua/plugins/ai/codecompanion.lua index b464538..7c4c30e 100644 --- a/lua/plugins/codecompanion.lua +++ b/lua/plugins/ai/codecompanion.lua @@ -4,23 +4,6 @@ return { dependencies = { { 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate' }, { 'nvim-lua/plenary.nvim' }, - -- Test with blink.cmp - { - 'saghen/blink.cmp', - lazy = false, - version = '*', - opts = { - keymap = { - preset = 'enter', - [''] = { 'select_prev', 'fallback' }, - [''] = { 'select_next', 'fallback' }, - }, - cmdline = { sources = { 'cmdline' } }, - sources = { - default = { 'lsp', 'path', 'buffer', 'codecompanion' }, - }, - }, - }, }, opts = { adapters = { @@ -40,7 +23,6 @@ return { }, --Refer to: https://github.com/olimorris/codecompanion.nvim/blob/main/lua/codecompanion/config.lua strategies = { - --NOTE: Change the adapter as required chat = { adapter = 'ollama', completion_provider = 'blink', -- blink|cmp|coc|default @@ -48,9 +30,6 @@ return { inline = { adapter = 'ollama' }, cmd = { adapter = 'ollama' }, }, - opts = { - log_level = 'DEBUG', - }, }, }, } diff --git a/lua/plugins/ai/cody.lua b/lua/plugins/ai/cody.lua new file mode 100644 index 0000000..df5a5dd --- /dev/null +++ b/lua/plugins/ai/cody.lua @@ -0,0 +1,20 @@ +return { + { + 'projects/cdy-nvim', + dir = '~/projects/cdy-nvim', + cmd = { 'CodyChat', 'CodyAsk', 'CodySetModel', 'CodyToggleFileContext', 'CodyToggleRepoContext', 'CodyNew' }, + dependencies = { + 'MunifTanjim/nui.nvim', + 'nvim-lua/plenary.nvim', + }, + keys = { + { 'cc', 'CodyChat', desc = 'Open cody chat' }, + { 'cn', 'CodyNew', desc = 'Start new cody chat' }, + }, + dev = true, + opts = { + include_file = true, + include_repo = true, + }, + }, +} diff --git a/lua/plugins/ai/init.lua b/lua/plugins/ai/init.lua new file mode 100644 index 0000000..f6b44e9 --- /dev/null +++ b/lua/plugins/ai/init.lua @@ -0,0 +1,6 @@ +local file = vim.fn.glob '~/projects/cdy-nvim' +if file ~= '' then + return require 'plugins.ai.cody' +else + return require 'plugins.ai.codecompanion' +end diff --git a/lua/plugins/dap.lua b/lua/plugins/dap/init.lua similarity index 86% rename from lua/plugins/dap.lua rename to lua/plugins/dap/init.lua index 45069cd..30e4b3c 100644 --- a/lua/plugins/dap.lua +++ b/lua/plugins/dap/init.lua @@ -26,10 +26,14 @@ return { require('nvim-dap-virtual-text').setup {} local dir = vim.fn.getcwd(0) - local contents = vim.fn.readblob(dir .. '/launch.json') - local prj_confs = vim.json.decode(contents) - local all_confs = prj_confs.configurations or {} + local file = vim.fn.glob(dir .. '/launch.json') + local prj_confs = {} + if file ~= '' then + local contents = vim.fn.readblob(dir .. '/launch.json') + prj_confs = vim.json.decode(contents) + end + local all_confs = prj_confs.configurations or {} local global_confs = require 'plugins.dap.configurations' for _, conf in ipairs(global_confs) do table.insert(all_confs, conf) diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/git.lua similarity index 76% rename from lua/plugins/gitsigns.lua rename to lua/plugins/git.lua index 4a96462..a267f45 100644 --- a/lua/plugins/gitsigns.lua +++ b/lua/plugins/git.lua @@ -1,4 +1,11 @@ return { + { -- Git integrations + 'tpope/vim-fugitive', + cmd = { 'G', 'Git' }, + keys = { + { 'gg', 'Git', desc = 'Open git fugitive' }, + }, + }, { -- Adds git related signs to the gutter, as well as utilities for managing changes 'lewis6991/gitsigns.nvim', lazy = false, diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 51c54ba..fbe0e2c 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -1,36 +1,4 @@ return { - -- NOTE: [ THEMES ] - -- { - -- 'yorumicolors/yorumi.nvim', - -- }, - -- { - -- 'savq/melange-nvim', - -- }, - -- { - -- 'sainnhe/gruvbox-material', - -- lazy = false, - -- config = function() - -- vim.g.gruvbox_material_background = 'medium' - -- vim.g.gruvbox_material_enable_italic = true - -- vim.cmd 'colorscheme gruvbox-material' - -- end, - -- }, - { - 'rebelot/kanagawa.nvim', - lazy = false, - config = function() - vim.cmd 'colorscheme kanagawa' - end, - }, - - { -- Git integrations - 'tpope/vim-fugitive', - cmd = { 'G', 'Git' }, - keys = { - { 'gg', 'Git', desc = 'Open git fugitive' }, - }, - }, - { -- traverse undotree 'mbbill/undotree', keys = { @@ -63,19 +31,6 @@ return { opts = {}, }, - { - -- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins - -- used for completion, annotations and signatures of Neovim apis - 'folke/lazydev.nvim', - ft = 'lua', - opts = { - library = { - -- Load luvit types when the `vim.uv` word is found - { path = '${3rd}/luv/library', words = { 'vim%.uv' } }, - }, - }, - }, - { 'nmac427/guess-indent.nvim', Event = 'BufEnter', diff --git a/lua/plugins/conform.lua b/lua/plugins/lsp/conform.lua similarity index 100% rename from lua/plugins/conform.lua rename to lua/plugins/lsp/conform.lua diff --git a/lua/lsp/golangci_lint_ls.lua b/lua/plugins/lsp/golangci_lint_ls.lua similarity index 100% rename from lua/lsp/golangci_lint_ls.lua rename to lua/plugins/lsp/golangci_lint_ls.lua diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp/init.lua similarity index 65% rename from lua/plugins/lsp.lua rename to lua/plugins/lsp/init.lua index 6f04359..3e2f04e 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp/init.lua @@ -1,4 +1,4 @@ -return { +return TableConcat(require 'plugins.lsp.conform', { { 'neovim/nvim-lspconfig', dependencies = { @@ -18,9 +18,21 @@ return { }, ft = { 'lua', 'elixir', 'go', 'erlang', 'typescript', 'typescriptreact', 'rust' }, config = function() - require('lsp').setup() + require('plugins.lsp.setup').setup() end, }, + { + -- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins + -- used for completion, annotations and signatures of Neovim apis + 'folke/lazydev.nvim', + ft = 'lua', + opts = { + library = { + -- Load luvit types when the `vim.uv` word is found + { path = '${3rd}/luv/library', words = { 'vim%.uv' } }, + }, + }, + }, { 'windwp/nvim-ts-autotag', ft = { 'javascriptreact', 'typescriptreact', 'html' }, @@ -33,4 +45,4 @@ return { }, }, }, -} +}) diff --git a/lua/lsp/lua_ls.lua b/lua/plugins/lsp/lua_ls.lua similarity index 100% rename from lua/lsp/lua_ls.lua rename to lua/plugins/lsp/lua_ls.lua diff --git a/lua/lsp/on_attach.lua b/lua/plugins/lsp/on_attach.lua similarity index 100% rename from lua/lsp/on_attach.lua rename to lua/plugins/lsp/on_attach.lua diff --git a/lua/lsp/init.lua b/lua/plugins/lsp/setup.lua similarity index 85% rename from lua/lsp/init.lua rename to lua/plugins/lsp/setup.lua index 45667c6..69a0a13 100644 --- a/lua/lsp/init.lua +++ b/lua/plugins/lsp/setup.lua @@ -21,13 +21,13 @@ function M.setup() }, }, }, - golangci_lint_ls = require 'lsp.golangci_lint_ls', + golangci_lint_ls = require 'plugins.lsp.golangci_lint_ls', erlangls = { cmd = { '/home/fergusmolloy/.local/bin/erlang_ls' }, filetypes = { 'erlang' } }, elixirls = { cmd = { 'elixir-ls' }, filetypes = { 'elixir' } }, - lua_ls = require 'lsp.lua_ls', + lua_ls = require 'plugins.lsp.lua_ls', } - local on_attach = require 'lsp.on_attach' + local on_attach = require 'plugins.lsp.on_attach' local lspconfig = require 'lspconfig' for server, config in pairs(servers) do @@ -39,7 +39,7 @@ function M.setup() end config.capabilities = require('blink.cmp').get_lsp_capabilities(config.capabilities) - config.on_attach = require 'lsp.on_attach' + config.on_attach = require 'plugins.lsp.on_attach' vim.lsp.enable(server) vim.lsp.config(server, config) diff --git a/lua/lsp/utils.lua b/lua/plugins/lsp/utils.lua similarity index 100% rename from lua/lsp/utils.lua rename to lua/plugins/lsp/utils.lua diff --git a/lua/plugins/noice.lua b/lua/plugins/noice.lua deleted file mode 100644 index a9e29c6..0000000 --- a/lua/plugins/noice.lua +++ /dev/null @@ -1,49 +0,0 @@ -return {} --- { --- 'folke/noice.nvim', --- dependencies = { --- 'MunifTanjim/nui.nvim', --- }, --- Event = 'VeryLazy', --- opts = { --- lsp = { --- -- override markdown rendering so that **cmp** and other plugins use **Treesitter** --- override = { --- ['vim.lsp.util.convert_input_to_markdown_lines'] = true, --- ['vim.lsp.util.stylize_markdown'] = true, --- ['cmp.entry.get_documentation'] = true, -- requires hrsh7th/nvim-cmp --- }, --- }, --- -- you can enable a preset for easier configuration --- presets = { --- bottom_search = true, -- use a classic bottom cmdline for search --- command_palette = true, -- position the cmdline and popupmenu together --- long_message_to_split = true, -- long messages will be sent to a split --- inc_rename = false, -- enables an input dialog for inc-rename.nvim --- lsp_doc_border = false, -- add a border to hover docs and signature help --- }, --- messages = { --- enabled = true, --- view_search = false, --- }, --- popupmenu = { --- enabled = true, --- }, --- -- filter out annoying erlangls messages --- routes = { --- { --- filter = { --- event = 'lsp', --- kind = 'progress', --- find = 'Indexing', --- cond = function(message) --- local client = vim.tbl_get(message.opts, 'progress', 'client') --- return client == 'erlangls' --- end, --- }, --- opts = { skip = true }, --- }, --- }, --- }, --- }, --- } diff --git a/lua/plugins/notes.lua b/lua/plugins/obsidian.lua similarity index 100% rename from lua/plugins/notes.lua rename to lua/plugins/obsidian.lua diff --git a/lua/plugins/theme.lua b/lua/plugins/theme.lua new file mode 100644 index 0000000..1edff40 --- /dev/null +++ b/lua/plugins/theme.lua @@ -0,0 +1,25 @@ +return { + -- NOTE: [ THEMES ] + -- { + -- 'yorumicolors/yorumi.nvim', + -- }, + -- { + -- 'savq/melange-nvim', + -- }, + -- { + -- 'sainnhe/gruvbox-material', + -- lazy = false, + -- config = function() + -- vim.g.gruvbox_material_background = 'medium' + -- vim.g.gruvbox_material_enable_italic = true + -- vim.cmd 'colorscheme gruvbox-material' + -- end, + -- }, + { + 'rebelot/kanagawa.nvim', + lazy = false, + config = function() + vim.cmd 'colorscheme kanagawa' + end, + }, +}