Compare commits
3 Commits
c7d39fe79c
...
f6c23ab11a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6c23ab11a | ||
|
|
ca3a910401 | ||
|
|
62b3b156fa |
@@ -20,11 +20,11 @@ vim.api.nvim_create_autocmd('FocusLost', {
|
|||||||
command = 'silent! wa', -- Save all files when moving away from the window
|
command = 'silent! wa', -- Save all files when moving away from the window
|
||||||
})
|
})
|
||||||
|
|
||||||
-- vim.api.nvim_create_autocmd('InsertLeave', {
|
vim.api.nvim_create_autocmd('InsertLeave', {
|
||||||
-- group = autosave_group,
|
group = autosave_group,
|
||||||
-- pattern = '*',
|
pattern = '*',
|
||||||
-- command = 'silent! wa', -- Save all files when leaving insert mode
|
command = 'silent! wa', -- Save all files when leaving insert mode
|
||||||
-- })
|
})
|
||||||
|
|
||||||
-- vim.api.nvim_create_autocmd('TextChanged', {
|
-- vim.api.nvim_create_autocmd('TextChanged', {
|
||||||
-- group = autosave_group,
|
-- group = autosave_group,
|
||||||
@@ -94,4 +94,15 @@ vim.api.nvim_create_autocmd('BufNewFile', {
|
|||||||
command = 'call feedkeys("i")',
|
command = 'call feedkeys("i")',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Reload LuaSnip snippets when saving files in the snippets directory
|
||||||
|
local snippets_dir = vim.fn.stdpath 'config' .. '/lua/snippets'
|
||||||
|
vim.api.nvim_create_autocmd('BufWritePost', {
|
||||||
|
pattern = snippets_dir .. '/*.json', -- Adjust the path to match your snippets directory
|
||||||
|
desc = 'Reload LuaSnip snippets on save',
|
||||||
|
callback = function()
|
||||||
|
require('luasnip.loaders.from_vscode').lazy_load { paths = { snippets_dir } }
|
||||||
|
vim.notify('Snippets reloaded!', vim.log.levels.INFO)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
require('helpers').edit_cf('a', '/lua/autocmd.lua')
|
require('helpers').edit_cf('a', '/lua/autocmd.lua')
|
||||||
|
|||||||
@@ -75,9 +75,10 @@ end, { desc = 'Open terminal' })
|
|||||||
-- Editing helpers
|
-- Editing helpers
|
||||||
vim.keymap.set('i', '<C-O>', '<Esc>o', { desc = 'Add line below' })
|
vim.keymap.set('i', '<C-O>', '<Esc>o', { desc = 'Add line below' })
|
||||||
vim.keymap.set('i', '<C-S-O>', '<Esc>O', { desc = 'Add line above' })
|
vim.keymap.set('i', '<C-S-O>', '<Esc>O', { desc = 'Add line above' })
|
||||||
vim.keymap.set('i', 'jj', '<Esc>', { desc = 'Exit insert mode' })
|
local esc_keys = { 'jj', 'jk', 'kk' }
|
||||||
vim.keymap.set('i', 'jk', '<Esc>', { desc = 'Exit insert mode' })
|
for _, key in ipairs(esc_keys) do
|
||||||
vim.keymap.set('i', 'kk', '<Esc>', { desc = 'Exit insert mode' })
|
vim.keymap.set('i', key, '<Esc>', { desc = 'Exit insert mode' })
|
||||||
|
end
|
||||||
vim.keymap.set('i', '<C-D>', '<Esc>ddi', { desc = 'Delete line' })
|
vim.keymap.set('i', '<C-D>', '<Esc>ddi', { desc = 'Delete line' })
|
||||||
vim.keymap.set('i', '<Leader>;', '<Esc>mzA;<Esc>`za', { desc = 'Append a semicolon' })
|
vim.keymap.set('i', '<Leader>;', '<Esc>mzA;<Esc>`za', { desc = 'Append a semicolon' })
|
||||||
vim.keymap.set('n', '<Leader>;', 'mzA;<Esc>`za', { desc = 'Append a semicolon' })
|
vim.keymap.set('n', '<Leader>;', 'mzA;<Esc>`za', { desc = 'Append a semicolon' })
|
||||||
@@ -119,8 +120,71 @@ vim.keymap.set('n', '<Leader>]', '<CMD>cnext<CR>', { desc = 'Next item in quickf
|
|||||||
vim.keymap.set('n', '<Leader>[', '<CMD>cprevious<CR>', { desc = 'Previous item in quickfix list' })
|
vim.keymap.set('n', '<Leader>[', '<CMD>cprevious<CR>', { desc = 'Previous item in quickfix list' })
|
||||||
vim.keymap.set('n', 'gd', '<CMD>Telescope lsp_definitions<CR>', { desc = 'Go to definition' })
|
vim.keymap.set('n', 'gd', '<CMD>Telescope lsp_definitions<CR>', { desc = 'Go to definition' })
|
||||||
|
|
||||||
|
local function open_test()
|
||||||
|
require('neotest').summary.open()
|
||||||
|
require('neotest').output_panel.open()
|
||||||
|
end
|
||||||
|
-- Testing
|
||||||
|
local test_maps = {
|
||||||
|
{
|
||||||
|
keys = { '<F12>', '<Leader>tn' },
|
||||||
|
action = function()
|
||||||
|
require('neotest').run.run()
|
||||||
|
open_test()
|
||||||
|
end,
|
||||||
|
desc = 'Run nearest test',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
keys = { '<F9>', '<Leader>ta' },
|
||||||
|
action = function()
|
||||||
|
require('neotest').run.run { suite = true }
|
||||||
|
open_test()
|
||||||
|
end,
|
||||||
|
desc = 'Run all tests in the project',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
keys = { '<F11>', '<Leader>tp' },
|
||||||
|
action = function()
|
||||||
|
require('neotest').run.run_last()
|
||||||
|
open_test()
|
||||||
|
end,
|
||||||
|
desc = 'Run previous test again',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
keys = { '<F10>', '<Leader>td' },
|
||||||
|
action = function()
|
||||||
|
require('neotest').run.run_last { strategy = 'dap' }
|
||||||
|
require('neotest').summary.open() -- Note: Doesn't call open_test() like the others
|
||||||
|
end,
|
||||||
|
desc = 'Run last test with debugger',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, map_info in ipairs(test_maps) do
|
||||||
|
for _, key in ipairs(map_info.keys) do
|
||||||
|
vim.keymap.set('n', key, map_info.action, { desc = map_info.desc })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
vim.keymap.set('n', '<Leader>tf', function()
|
||||||
|
require('neotest').run.run(vim.fn.expand '%')
|
||||||
|
open_test()
|
||||||
|
end, { desc = 'Run all tests in the current file' })
|
||||||
|
vim.keymap.set('n', '<Leader>tc', function()
|
||||||
|
require('neotest').summary.close()
|
||||||
|
require('neotest').output_panel.close()
|
||||||
|
end, { desc = 'Close test panels' })
|
||||||
|
|
||||||
-- Leaving this commented out, I will try the format command instead
|
-- Leaving this commented out, I will try the format command instead
|
||||||
-- "A command to properly indent json code
|
-- "A command to properly indent json code
|
||||||
-- command! FormatJSON %!python -m json.tool
|
-- command! FormatJSON %!python -m json.tool
|
||||||
|
|
||||||
|
-- Edit the snippet file for the current buffer filetype or the snippets
|
||||||
|
-- directory if the file does not exist
|
||||||
|
vim.keymap.set('n', '<Leader>es', function()
|
||||||
|
local ft = vim.bo.filetype
|
||||||
|
local snippets_dir = vim.fn.stdpath 'config' .. '/lua/snippets'
|
||||||
|
local snippets_file = snippets_dir .. '/' .. ft .. '.json'
|
||||||
|
vim.cmd('tabedit ' .. snippets_file)
|
||||||
|
end, { desc = 'Edit snippets file' })
|
||||||
|
|
||||||
require('helpers').edit_cf('k', '/lua/keymap.lua')
|
require('helpers').edit_cf('k', '/lua/keymap.lua')
|
||||||
|
|||||||
@@ -82,4 +82,6 @@ vim.opt.autowriteall = true
|
|||||||
-- Add lines at 80 and 120 columns
|
-- Add lines at 80 and 120 columns
|
||||||
vim.opt.colorcolumn = '80,120'
|
vim.opt.colorcolumn = '80,120'
|
||||||
|
|
||||||
|
vim.opt.iskeyword:remove '$'
|
||||||
|
|
||||||
require('helpers').edit_cf('o', '/lua/opt.lua')
|
require('helpers').edit_cf('o', '/lua/opt.lua')
|
||||||
|
|||||||
@@ -7,31 +7,7 @@ return {
|
|||||||
-- Compatibility for Avante with Blink (it typically only works with cmp)
|
-- Compatibility for Avante with Blink (it typically only works with cmp)
|
||||||
-- 'Kaiser-Yang/blink-cmp-avante',
|
-- 'Kaiser-Yang/blink-cmp-avante',
|
||||||
-- Snippet Engine
|
-- Snippet Engine
|
||||||
{
|
|
||||||
'L3MON4D3/LuaSnip',
|
'L3MON4D3/LuaSnip',
|
||||||
version = '2.*',
|
|
||||||
build = (function()
|
|
||||||
-- Build Step is needed for regex support in snippets.
|
|
||||||
-- This step is not supported in many windows environments.
|
|
||||||
-- Remove the below condition to re-enable on windows.
|
|
||||||
if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
return 'make install_jsregexp'
|
|
||||||
end)(),
|
|
||||||
dependencies = {
|
|
||||||
-- `friendly-snippets` contains a variety of premade snippets.
|
|
||||||
-- See the README about individual language/framework/plugin snippets:
|
|
||||||
-- https://github.com/rafamadriz/friendly-snippets
|
|
||||||
{
|
|
||||||
'rafamadriz/friendly-snippets',
|
|
||||||
config = function()
|
|
||||||
require('luasnip.loaders.from_vscode').lazy_load()
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
opts = {},
|
|
||||||
},
|
|
||||||
'folke/lazydev.nvim',
|
'folke/lazydev.nvim',
|
||||||
},
|
},
|
||||||
--- @module 'blink.cmp'
|
--- @module 'blink.cmp'
|
||||||
|
|||||||
@@ -4,12 +4,51 @@ return {
|
|||||||
'olimorris/codecompanion.nvim',
|
'olimorris/codecompanion.nvim',
|
||||||
opts = function(_, opts)
|
opts = function(_, opts)
|
||||||
opts.adapters = {
|
opts.adapters = {
|
||||||
copilot = function()
|
gpt = function()
|
||||||
return require('codecompanion.adapters').extend('copilot', {
|
return require('codecompanion.adapters').extend('copilot', {
|
||||||
schema = {
|
schema = {
|
||||||
model = {
|
model = {
|
||||||
default = 'gpt-4o',
|
default = 'gpt-4o',
|
||||||
},
|
},
|
||||||
|
max_tokens = {
|
||||||
|
default = 1000000,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
flash = function()
|
||||||
|
return require('codecompanion.adapters').extend('copilot', {
|
||||||
|
schema = {
|
||||||
|
model = {
|
||||||
|
default = 'gemini-2.0-flash',
|
||||||
|
},
|
||||||
|
max_tokens = {
|
||||||
|
default = 1000000,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
gemini = function()
|
||||||
|
return require('codecompanion.adapters').extend('copilot', {
|
||||||
|
schema = {
|
||||||
|
model = {
|
||||||
|
default = 'gemini-2.5-pro',
|
||||||
|
},
|
||||||
|
max_tokens = {
|
||||||
|
default = 1000000,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
sonnet = function()
|
||||||
|
return require('codecompanion.adapters').extend('copilot', {
|
||||||
|
schema = {
|
||||||
|
model = {
|
||||||
|
default = 'claude-3.7-sonnet',
|
||||||
|
},
|
||||||
|
max_tokens = {
|
||||||
|
default = 1000000,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
@@ -23,7 +62,7 @@ return {
|
|||||||
|
|
||||||
opts.strategies = {
|
opts.strategies = {
|
||||||
chat = {
|
chat = {
|
||||||
adapter = 'copilot',
|
adapter = 'gemini',
|
||||||
slash_commands = {
|
slash_commands = {
|
||||||
codebase = require('vectorcode.integrations').codecompanion.chat.make_slash_command(),
|
codebase = require('vectorcode.integrations').codecompanion.chat.make_slash_command(),
|
||||||
},
|
},
|
||||||
@@ -34,6 +73,9 @@ return {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
inline = {
|
||||||
|
adapter = 'flash',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
dependencies = {
|
dependencies = {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
require('helpers').edit_cf('pd', '/lua/plugins/debug.lua')
|
||||||
-- debug.lua
|
-- debug.lua
|
||||||
--
|
--
|
||||||
-- Shows how to use the DAP plugin to debug your code.
|
-- Shows how to use the DAP plugin to debug your code.
|
||||||
@@ -96,6 +97,26 @@ return {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dap.adapters.php = {
|
||||||
|
type = 'executable',
|
||||||
|
command = 'node',
|
||||||
|
args = { '/Users/chris/.local/src/vscode-php-debug/out/phpDebug.js' },
|
||||||
|
}
|
||||||
|
|
||||||
|
dap.configurations.php = {
|
||||||
|
{
|
||||||
|
type = 'php',
|
||||||
|
request = 'launch',
|
||||||
|
name = 'Listen for XDebug',
|
||||||
|
port = 9003,
|
||||||
|
log = true,
|
||||||
|
pathMappings = {
|
||||||
|
['/var/www/html/'] = vim.fn.getcwd() .. '/',
|
||||||
|
},
|
||||||
|
hostname = '0.0.0.0',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
-- Dap UI setup
|
-- Dap UI setup
|
||||||
-- For more information, see |:help nvim-dap-ui|
|
-- For more information, see |:help nvim-dap-ui|
|
||||||
dapui.setup {
|
dapui.setup {
|
||||||
|
|||||||
31
lua/plugins/snippets.lua
Normal file
31
lua/plugins/snippets.lua
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
return {
|
||||||
|
'L3MON4D3/LuaSnip',
|
||||||
|
version = '2.*',
|
||||||
|
build = (function()
|
||||||
|
-- Build Step is needed for regex support in snippets.
|
||||||
|
-- This step is not supported in many windows environments.
|
||||||
|
-- Remove the below condition to re-enable on windows.
|
||||||
|
if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
return 'make install_jsregexp'
|
||||||
|
end)(),
|
||||||
|
config = function()
|
||||||
|
local snippets_dir = vim.fn.stdpath 'config' .. '/lua/snippets'
|
||||||
|
require('luasnip.loaders.from_vscode').lazy_load {
|
||||||
|
paths = { snippets_dir },
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
dependencies = {
|
||||||
|
-- `friendly-snippets` contains a variety of premade snippets.
|
||||||
|
-- See the README about individual language/framework/plugin snippets:
|
||||||
|
-- https://github.com/rafamadriz/friendly-snippets
|
||||||
|
{
|
||||||
|
'rafamadriz/friendly-snippets',
|
||||||
|
config = function()
|
||||||
|
require('luasnip.loaders.from_vscode').lazy_load()
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
opts = {},
|
||||||
|
}
|
||||||
@@ -5,4 +5,7 @@ return {
|
|||||||
dependencies = { 'nvim-lua/plenary.nvim' },
|
dependencies = { 'nvim-lua/plenary.nvim' },
|
||||||
build = 'pipx upgrade vectorcode',
|
build = 'pipx upgrade vectorcode',
|
||||||
cmd = 'VectorCode', -- if you're lazy-loading VectorCode
|
cmd = 'VectorCode', -- if you're lazy-loading VectorCode
|
||||||
|
opts = {
|
||||||
|
async_backend = 'lsp',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
1
lua/snippets/all.json
Normal file
1
lua/snippets/all.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{}
|
||||||
9
lua/snippets/javascript-vue.json
Normal file
9
lua/snippets/javascript-vue.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"Log function": {
|
||||||
|
"prefix": "du",
|
||||||
|
"body": [
|
||||||
|
"console.log($0);"
|
||||||
|
],
|
||||||
|
"description": "Log variable"
|
||||||
|
}
|
||||||
|
}
|
||||||
26
lua/snippets/package.json
Normal file
26
lua/snippets/package.json
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"name": "example-snippets",
|
||||||
|
"contributes": {
|
||||||
|
"snippets": [
|
||||||
|
{
|
||||||
|
"language": [
|
||||||
|
"all"
|
||||||
|
],
|
||||||
|
"path": "./snippets/all.json"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"language": [
|
||||||
|
"php"
|
||||||
|
],
|
||||||
|
"path": "./php.json"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"language": [
|
||||||
|
"javascript",
|
||||||
|
"vue"
|
||||||
|
],
|
||||||
|
"path": "./javascript-vue.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
17
lua/snippets/php.json
Normal file
17
lua/snippets/php.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"Create doc block": {
|
||||||
|
"prefix": "/**",
|
||||||
|
"body": [
|
||||||
|
"/**",
|
||||||
|
" * $0",
|
||||||
|
" */"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Dump function": {
|
||||||
|
"prefix": "du",
|
||||||
|
"body": [
|
||||||
|
"dump($0);"
|
||||||
|
],
|
||||||
|
"description": "Dump variable"
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user