re-organised config

This commit is contained in:
Fergus Molloy
2025-06-19 14:31:13 +01:00
parent 309b47ceb5
commit ec9a456c74
18 changed files with 91 additions and 183 deletions

View File

@ -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 = {
{ '<leader>cc', '<cmd>CodyChat<cr>', desc = 'Open cody chat' },
{ '<leader>cn', '<cmd>CodyNew<cr>', 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 = "<Leader>ci"
-- let g:claude_map_open_chat = "<Leader>cc"
-- let g:claude_map_send_chat_message = "<C-]>"
-- let g:claude_map_cancel_response = "<Leader>cx"
-- ]]
-- end,
-- },
}
end

View File

@ -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',
['<S-Tab>'] = { 'select_prev', 'fallback' },
['<Tab>'] = { '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',
},
},
},
}

20
lua/plugins/ai/cody.lua Normal file
View File

@ -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 = {
{ '<leader>cc', '<cmd>CodyChat<cr>', desc = 'Open cody chat' },
{ '<leader>cn', '<cmd>CodyNew<cr>', desc = 'Start new cody chat' },
},
dev = true,
opts = {
include_file = true,
include_repo = true,
},
},
}

6
lua/plugins/ai/init.lua Normal file
View File

@ -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

View File

@ -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)

View File

@ -1,4 +1,11 @@
return {
{ -- Git integrations
'tpope/vim-fugitive',
cmd = { 'G', 'Git' },
keys = {
{ '<leader>gg', '<cmd>Git<cr>', desc = 'Open git fugitive' },
},
},
{ -- Adds git related signs to the gutter, as well as utilities for managing changes
'lewis6991/gitsigns.nvim',
lazy = false,

View File

@ -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 = {
{ '<leader>gg', '<cmd>Git<cr>', 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',

View File

@ -0,0 +1,19 @@
return {
enable = function() -- disable lsp if wrong version installed
local enable = true
vim
.system({ 'golangci-lint', '--version' }, { text = true }, function(out)
if out.code ~= 0 then
enable = false
return
end
if out.stdout:match ' 1%.%d+%.%d+' then
enable = false
return
end
end)
:wait()
return enable
end,
}

View File

@ -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 {
},
},
},
}
})

View File

@ -0,0 +1,34 @@
return {
on_init = function(client)
if client.workspace_folders then
local path = client.workspace_folders[1].name
if path ~= vim.fn.stdpath 'config' and (vim.uv.fs_stat(path .. '/.luarc.json') or vim.uv.fs_stat(path .. '/.luarc.jsonc')) then
return
end
end
client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
runtime = {
-- Tell the language server which version of Lua you're using
-- (most likely LuaJIT in the case of Neovim)
version = 'LuaJIT',
},
-- Make the server aware of Neovim runtime files
workspace = {
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME,
-- Depending on the usage, you might want to add additional paths here.
-- "${3rd}/luv/library"
-- "${3rd}/busted/library",
},
-- or pull in all of 'runtimepath'. NOTE: this is a lot slower and will cause issues when working on your own configuration (see https://github.com/neovim/nvim-lspconfig/issues/3189)
-- library = vim.api.nvim_get_runtime_file("", true)
},
})
end,
settings = {
Lua = {},
},
filetypes = { 'lua' },
}

View File

@ -0,0 +1,29 @@
return function(client, bufnr)
require('nvim-navbuddy').attach(client, bufnr)
local nmap = function(keys, func, desc)
if desc then
desc = 'LSP: ' .. desc
end
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
end
nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
nmap('gi', vim.lsp.buf.implementation, '[G]oto [I]mplementation')
nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[N]ame')
nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
nmap('K', vim.lsp.buf.hover, 'Hover docs')
-- Lesser used LSP functionality
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
nmap('<leader>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, '[W]orkspace [L]ist Folders')
nmap('<leader>e', vim.diagnostic.open_float, 'Open floating diagnostics')
nmap('<leader>q', vim.diagnostic.setloclist, 'Open diagnostics list')
end

50
lua/plugins/lsp/setup.lua Normal file
View File

@ -0,0 +1,50 @@
local M = {}
function M.setup()
local servers = {
ts_ls = { filetypes = { 'javascript', 'typescript', 'javascriptreact', 'typescriptreact' } },
gopls = { filetypes = { 'go', 'gomod' } },
rust_analyzer = {
filetypes = { 'rust' },
settings = {
['rust-analyzer'] = {
check = {
command = 'clippy',
extraArgs = {
'--',
'-Dclippy::correctness',
'-Wclippy::complexity',
'-Wclippy::pedantic',
'-Wclippy::perf',
},
},
},
},
},
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 'plugins.lsp.lua_ls',
}
local on_attach = require 'plugins.lsp.on_attach'
local lspconfig = require 'lspconfig'
for server, config in pairs(servers) do
if config['enable'] then
if not config.enable() then
vim.notify('Disabling language server ' .. server, vim.log.levels.WARN)
goto continue
end
end
config.capabilities = require('blink.cmp').get_lsp_capabilities(config.capabilities)
config.on_attach = require 'plugins.lsp.on_attach'
vim.lsp.enable(server)
vim.lsp.config(server, config)
::continue::
end
end
return M

15
lua/plugins/lsp/utils.lua Normal file
View File

@ -0,0 +1,15 @@
local M = {}
function M.check_ft(server, config)
if config.filetypes == nil or next(config.filetypes) == nil then
return true -- if no filetypes specified then enable
else
config.server = server
for _, ft in ipairs(config.filetypes) do
if vim.bo[0].filetype == ft then
return true
end
end
end
return false
end
return M

View File

@ -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 },
-- },
-- },
-- },
-- },
-- }

25
lua/plugins/theme.lua Normal file
View File

@ -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,
},
}