pre-ai-alter
This commit is contained in:
parent
e1c533e1c4
commit
3af68c2c76
103
CURSOR_COMPLETION.md
Normal file
103
CURSOR_COMPLETION.md
Normal file
@ -0,0 +1,103 @@
|
||||
# Cursor Autocompletion for Neovim
|
||||
|
||||
This setup integrates Cursor's AI-powered autocompletion into Neovim using `cursor-agent` CLI and `nvim-cmp`.
|
||||
|
||||
## Features
|
||||
|
||||
- **AI-powered completions**: Get intelligent code completions powered by Cursor's AI
|
||||
- **Context-aware**: Uses surrounding code context (last 30 lines) for better suggestions
|
||||
- **Integrated with nvim-cmp**: Works seamlessly with other completion sources (LSP, snippets, buffer, etc.)
|
||||
- **Prioritized suggestions**: Cursor completions appear at the top of the completion menu
|
||||
|
||||
## Setup
|
||||
|
||||
The integration is already configured! Just make sure:
|
||||
|
||||
1. **cursor-agent CLI is installed and authenticated**:
|
||||
```bash
|
||||
cursor-agent status
|
||||
```
|
||||
If not authenticated, run:
|
||||
```bash
|
||||
cursor-agent login
|
||||
```
|
||||
|
||||
2. **Restart Neovim** to load the new configuration
|
||||
|
||||
3. **Install plugins** (if using lazy.nvim, they'll auto-install):
|
||||
```vim
|
||||
:Lazy sync
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
1. **Start typing** in any file
|
||||
2. **Press `<C-Space>`** to trigger completion manually, or wait for automatic triggers
|
||||
3. **Look for `[Cursor]`** in the completion menu to see AI suggestions
|
||||
4. **Navigate** with `<Tab>`/`<S-Tab>` and **accept** with `<Enter>`
|
||||
|
||||
## Configuration
|
||||
|
||||
### Keybindings
|
||||
|
||||
Default keybindings (can be customized in `lua/config/plugin/cmp.lua`):
|
||||
- `<C-Space>` - Trigger completion
|
||||
- `<Tab>` - Next completion item / Expand snippet
|
||||
- `<S-Tab>` - Previous completion item / Jump snippet backward
|
||||
- `<Enter>` - Confirm completion
|
||||
- `<C-e>` - Close completion menu
|
||||
|
||||
### Adjusting Completion Behavior
|
||||
|
||||
Edit `lua/plugins/cmp-cursor.lua` to customize:
|
||||
- **Context window**: Change `line_num - 30` to adjust how many lines of context are sent
|
||||
- **Minimum trigger length**: Change `#before_cursor:gsub('%s+', '') < 3` to require more/less context
|
||||
- **Timeout**: Change `8000` (8 seconds) to adjust how long to wait for completions
|
||||
|
||||
### Disabling Cursor Completions
|
||||
|
||||
To temporarily disable Cursor completions, comment out the cursor source in `lua/config/plugin/cmp.lua`:
|
||||
|
||||
```lua
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
-- { name = 'cursor', source = cursor_completion_source }, -- Disabled
|
||||
{ name = 'luasnip' },
|
||||
}, {
|
||||
```
|
||||
|
||||
## How It Works
|
||||
|
||||
1. When you trigger completion, the plugin captures:
|
||||
- Current line up to cursor position
|
||||
- Last 30 lines of context
|
||||
- File content
|
||||
|
||||
2. It sends a prompt to `cursor-agent --print` asking for completion suggestions
|
||||
|
||||
3. The AI response is parsed and formatted as completion items
|
||||
|
||||
4. These appear in the nvim-cmp completion menu with `[Cursor]` label
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
**No Cursor completions appearing:**
|
||||
- Check `cursor-agent status` to ensure you're authenticated
|
||||
- Verify `cursor-agent` is in your PATH: `which cursor-agent`
|
||||
- Check Neovim messages: `:messages` for any errors
|
||||
|
||||
**Completions are slow:**
|
||||
- This is expected - AI completions take 2-8 seconds
|
||||
- Consider increasing the minimum trigger length to reduce API calls
|
||||
- The timeout is set to 8 seconds
|
||||
|
||||
**Completions don't make sense:**
|
||||
- The AI uses context from your file - ensure you have meaningful code before the cursor
|
||||
- Try typing more context before triggering completion
|
||||
|
||||
## Notes
|
||||
|
||||
- Cursor completions use API credits from your Cursor account
|
||||
- Completions are generated on-demand, not cached
|
||||
- The integration works best with code files (not plain text)
|
||||
- For best results, ensure your code is syntactically correct before requesting completions
|
||||
144
README.md
Normal file
144
README.md
Normal file
@ -0,0 +1,144 @@
|
||||
# Neovim Configuration Summary
|
||||
|
||||
## Plugin Management
|
||||
- **Plugin Manager**: `lazy.nvim` (auto-bootstrapped)
|
||||
- **Leader Key**: `<Space>`
|
||||
- **Update Checker**: Enabled (silent notifications)
|
||||
|
||||
## Core Plugins & Features
|
||||
|
||||
### File Navigation & Search
|
||||
- **Telescope** (v0.1.8): Fuzzy finder for files, buffers, grep, help tags, marks
|
||||
- **nvim-tree**: File browser
|
||||
- **Tagbar**: Code structure viewer (properties/methods)
|
||||
|
||||
### LSP & Code Intelligence
|
||||
- **Mason + Mason-LSPConfig**: LSP server management
|
||||
- **nvim-lspconfig**: LSP client configuration
|
||||
- **Lspsaga**: Enhanced LSP UI (code actions, definitions, diagnostics, outline)
|
||||
- **nvim-cmp**: Completion engine with:
|
||||
- Buffer, path, LSP, cmdline sources
|
||||
- LuaSnip snippets
|
||||
- Custom Cursor AI completion source (`cursor-agent` integration)
|
||||
|
||||
### Syntax & Highlighting
|
||||
- **nvim-treesitter**: Syntax highlighting via language parsers
|
||||
- **nvim-colorizer**: Color previews (hex codes, etc.)
|
||||
- **SyntaxAttr**: Display syntax highlighting info
|
||||
- **Gruvbox**: Colorscheme
|
||||
|
||||
### UI Enhancements
|
||||
- **lualine**: Status bar
|
||||
- **nvim-scrollbar**: Scrollbar indicator
|
||||
- **indent-blankline**: Indentation guides
|
||||
- **rainbow-delimiters**: Color-coded brackets/braces
|
||||
- **deadcolumn**: Visual indicator near line limit
|
||||
- **alpha-nvim**: Custom welcome screen
|
||||
|
||||
### Git Integration
|
||||
- **vim-fugitive**: Git wrapper
|
||||
- **vim-gitgutter**: Git diff indicators in gutter
|
||||
|
||||
### Code Quality & Formatting
|
||||
- **conform.nvim**: Code formatter (configured for Lua with stylua)
|
||||
- **Trouble.nvim**: Diagnostics viewer
|
||||
|
||||
### Marks & Navigation
|
||||
- **marks.nvim**: Visual marks with gutter indicators
|
||||
- **vim-indentwise**: Indentation-based navigation
|
||||
|
||||
### Other Utilities
|
||||
- **undotree**: Visual undo history
|
||||
- **which-key.nvim**: Keybinding help menu
|
||||
- **toggleterm.nvim**: Floating terminal
|
||||
- **llama.vim**: Local AI integration (requires llama.cpp with CUDA)
|
||||
- **mini.nvim**: Mini utilities collection
|
||||
- **volt/menu**: Context menu system
|
||||
- **minty**: Color picker
|
||||
|
||||
## Key Bindings
|
||||
|
||||
### Telescope (`<leader>f`)
|
||||
- `ff` - Find files
|
||||
- `fg` - Live grep
|
||||
- `fb` - Find buffers
|
||||
- `fc` - Find in current buffer
|
||||
- `fh` - Help tags
|
||||
- `fm` - Marks
|
||||
- `fr` - Resume last search
|
||||
|
||||
### LSP (`<leader>l`)
|
||||
- `lc` - Code actions
|
||||
- `lo` - Outline
|
||||
- `lr` - Rename
|
||||
- `ld` - Go to definition
|
||||
- `lf` - LSP finder
|
||||
- `lp` - Preview definition
|
||||
- `lw` - Workspace diagnostics
|
||||
- `lb` - Buffer diagnostics
|
||||
- `lm` - LMS fixer (custom)
|
||||
|
||||
### Other Important Bindings
|
||||
- `<leader>u` - Undo tree
|
||||
- `<leader>m` - Marks management
|
||||
- `<leader>t` - Tab navigation
|
||||
- `<leader>b` - Buffer management
|
||||
- `<leader>i` - Indentation toggles
|
||||
- `<leader>n` - Remove search highlight
|
||||
- `<leader>e` - Show diagnostic
|
||||
- `<leader><F5>` - Definition in new tab
|
||||
- `<leader><F8>` - Tagbar toggle
|
||||
- `<C-k>` - LSP hover
|
||||
- `<C-]>` - Jump to definition in new tab
|
||||
- `<Tab>/<S-Tab>` - Tab navigation
|
||||
- `<C-h/j/k/l>` - Window navigation
|
||||
- `<C-m>` - Move split to tab
|
||||
- `<C-t>` - Context menu
|
||||
|
||||
## Editor Settings
|
||||
|
||||
### Display
|
||||
- True color support enabled
|
||||
- Cursor line/column highlighting
|
||||
- Line numbers
|
||||
- Color column at 81
|
||||
- Scroll offset: 5 lines
|
||||
- Sign column always visible
|
||||
|
||||
### Indentation & Formatting
|
||||
- Expand tabs to spaces
|
||||
- Tab width: 4 spaces
|
||||
- Smart indentation
|
||||
- Show whitespace characters (eol, tabs, trails)
|
||||
- No text wrapping
|
||||
|
||||
### Search
|
||||
- Case-insensitive (smart case)
|
||||
- Incremental search
|
||||
- Highlight search results
|
||||
- Wildignore case enabled
|
||||
|
||||
### Folding
|
||||
- Method: indent
|
||||
- Fold level: 99 (mostly open)
|
||||
- Fold column visible
|
||||
|
||||
### Behavior
|
||||
- Auto-read changed files
|
||||
- Arrow keys disabled (forces hjkl)
|
||||
- Mouse disabled
|
||||
- Shell commands run interactively (`-ic` flag)
|
||||
|
||||
## Special Features
|
||||
1. **Cursor AI Integration**: Custom completion source using `cursor-agent` for AI-powered completions
|
||||
2. **PHP Helper**: Custom function for inserting debug backtraces
|
||||
3. **Custom Aliases**: `Bufdel` command for buffer management
|
||||
4. **Quick Directory Navigation**: Shortcuts to LMS project directories (`<leader>c`)
|
||||
|
||||
## Architecture
|
||||
- Modular structure: config split into logical files
|
||||
- Plugin configs in `lua/config/plugin/`
|
||||
- Main entry point: `init.lua`
|
||||
- Uses Lua-based configuration throughout
|
||||
|
||||
This setup focuses on productivity with LSP integration, AI-assisted completion, and a clean UI.
|
||||
1
init.lua
1
init.lua
@ -5,4 +5,5 @@ require("config.lazy")
|
||||
require("config.keymaps")
|
||||
require("config.options")
|
||||
require("config.aliases")
|
||||
require("config.cmp-cursor")
|
||||
require("config.plugin")
|
||||
|
||||
161
lua/config/cmp-cursor.lua
Normal file
161
lua/config/cmp-cursor.lua
Normal file
@ -0,0 +1,161 @@
|
||||
-- Custom nvim-cmp source for Cursor Agent autocompletion
|
||||
local cmp = require('cmp')
|
||||
local source = {}
|
||||
|
||||
source.new = function()
|
||||
return setmetatable({}, { __index = source })
|
||||
end
|
||||
|
||||
source.is_available = function()
|
||||
-- Check if cursor-agent is available
|
||||
return vim.fn.executable('cursor-agent') == 1
|
||||
end
|
||||
|
||||
source.get_trigger_characters = function()
|
||||
return {}
|
||||
end
|
||||
|
||||
source.complete = function(self, request, callback)
|
||||
-- Only trigger if there's meaningful context (at least 3 characters typed)
|
||||
local bufnr = request.context.bufnr
|
||||
local cursor = vim.api.nvim_win_get_cursor(0)
|
||||
local line_num = cursor[1]
|
||||
local col_num = cursor[2] + 1 -- Convert to 1-indexed
|
||||
|
||||
-- Get current line and context
|
||||
local current_line = vim.api.nvim_buf_get_lines(bufnr, line_num - 1, line_num, false)[1] or ''
|
||||
local before_cursor = current_line:sub(1, col_num - 1)
|
||||
|
||||
-- Skip if too little context (less than 3 characters before cursor)
|
||||
if #before_cursor:gsub('%s+', '') < 3 then
|
||||
callback({ items = {} })
|
||||
return
|
||||
end
|
||||
|
||||
-- Get surrounding context (last 30 lines for better context)
|
||||
local start_line = math.max(0, line_num - 30)
|
||||
local context_lines = vim.api.nvim_buf_get_lines(bufnr, start_line, line_num, false)
|
||||
local context = table.concat(context_lines, '\n')
|
||||
|
||||
-- Build prompt for cursor-agent - optimized for completion
|
||||
local prompt = string.format(
|
||||
"Complete the code after the cursor. Return ONLY the text that should appear after the cursor position, nothing else. Do not include any explanation or the existing code.\n\nContext:\n%s\n\nComplete after cursor (|): %s|",
|
||||
context,
|
||||
before_cursor
|
||||
)
|
||||
|
||||
-- Call cursor-agent with --print flag
|
||||
local cmd = {
|
||||
'cursor-agent',
|
||||
'--print',
|
||||
'--output-format', 'text',
|
||||
prompt
|
||||
}
|
||||
|
||||
local completed = false
|
||||
local job_id = vim.fn.jobstart(cmd, {
|
||||
stdout_buffered = true,
|
||||
stderr_buffered = true,
|
||||
on_stdout = function(_, data, _)
|
||||
if completed then return end
|
||||
completed = true
|
||||
|
||||
if not data or #data == 0 then
|
||||
callback({ items = {} })
|
||||
return
|
||||
end
|
||||
|
||||
-- Parse completion suggestions
|
||||
local items = {}
|
||||
local full_text = table.concat(data, '\n'):gsub('%s+', ' '):gsub('^%s+', ''):gsub('%s+$', '')
|
||||
|
||||
if full_text and full_text ~= '' then
|
||||
-- Try to extract just the completion part
|
||||
-- Remove any text that matches the before_cursor context
|
||||
local completion = full_text
|
||||
|
||||
-- Clean up common prefixes that might be repeated
|
||||
if before_cursor ~= '' then
|
||||
local escaped_prefix = vim.pesc(before_cursor:match('[%w_]+$') or '')
|
||||
if escaped_prefix ~= '' then
|
||||
completion = completion:gsub('^' .. escaped_prefix, '')
|
||||
end
|
||||
end
|
||||
|
||||
-- Split into potential multiple completions (by lines or common patterns)
|
||||
if completion:find('\n') then
|
||||
-- Multiple lines - create separate items
|
||||
for line in completion:gmatch('[^\n]+') do
|
||||
line = line:gsub('^%s+', ''):gsub('%s+$', '')
|
||||
if line ~= '' and #line > 0 then
|
||||
table.insert(items, {
|
||||
label = line,
|
||||
kind = cmp.lsp.CompletionItemKind.Text,
|
||||
documentation = {
|
||||
kind = 'markdown',
|
||||
value = '**Cursor AI Completion**\n\n' .. line
|
||||
},
|
||||
sortText = '0' .. line, -- Prioritize Cursor completions
|
||||
})
|
||||
end
|
||||
end
|
||||
else
|
||||
-- Single line completion
|
||||
completion = completion:gsub('^%s+', ''):gsub('%s+$', '')
|
||||
if completion ~= '' and #completion > 0 then
|
||||
-- Create multiple suggestions: full completion, first word, etc.
|
||||
table.insert(items, {
|
||||
label = completion,
|
||||
kind = cmp.lsp.CompletionItemKind.Text,
|
||||
documentation = {
|
||||
kind = 'markdown',
|
||||
value = '**Cursor AI Completion**\n\n' .. completion
|
||||
},
|
||||
sortText = '0' .. completion,
|
||||
})
|
||||
|
||||
-- Also add first word/phrase as a shorter option
|
||||
local first_part = completion:match('^([%w_]+)') or completion:match('^([^%s]+)')
|
||||
if first_part and first_part ~= completion and #first_part > 2 then
|
||||
table.insert(items, {
|
||||
label = first_part,
|
||||
kind = cmp.lsp.CompletionItemKind.Text,
|
||||
documentation = {
|
||||
kind = 'markdown',
|
||||
value = '**Cursor AI Completion** (partial)\n\n' .. first_part
|
||||
},
|
||||
sortText = '1' .. first_part,
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
callback({ items = items })
|
||||
end,
|
||||
on_stderr = function(_, data, _)
|
||||
if completed then return end
|
||||
completed = true
|
||||
-- On error, return empty completions
|
||||
callback({ items = {} })
|
||||
end,
|
||||
on_exit = function(_, code, _)
|
||||
if completed then return end
|
||||
completed = true
|
||||
if code ~= 0 then
|
||||
callback({ items = {} })
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
-- Set timeout (8 seconds for AI completion)
|
||||
vim.defer_fn(function()
|
||||
if not completed and vim.fn.jobwait({ job_id }, 0)[1] == -1 then
|
||||
vim.fn.jobstop(job_id)
|
||||
completed = true
|
||||
callback({ items = {} })
|
||||
end
|
||||
end, 8000)
|
||||
end
|
||||
|
||||
return source
|
||||
@ -20,9 +20,9 @@ wk.add({
|
||||
{ "<leader>lr", "<cmd>Lspsaga rename<cr>", desc = "Rename", mode ="n"},
|
||||
{ "<leader>ld", "<cmd>Lspsaga goto_definition<cr>", desc = "Lsp GoTo Definition", mode ="n"},
|
||||
{ "<leader>lf", "<cmd>Lspsaga finder<cr>", desc = "Lsp Finder", mode ="n"},
|
||||
{ "<leader>lp", "<cmd>Lspsaga preview_definition<cr>", desc = "Preview Definition", mode ="n"},
|
||||
{ "<leader>ls", "<cmd>Lspsaga signature_help<cr>", desc = "Signature Help", mode ="n"},
|
||||
{ "<leader>lp", "<cmd>Lspsaga peek_definition<cr>", desc = "Preview Definition", mode ="n"},
|
||||
{ "<leader>lw", "<cmd>Lspsaga show_workspace_diagnostics<cr>", desc = "Show Workspace Diagnostics", mode ="n"},
|
||||
{ "<leader>lb", "<cmd>Lspsaga show_buf_diagnostics<cr>", desc = "Show Buffer Diagnostics", mode ="n"},
|
||||
{ "<leader>lm", "<cmd>TermExec cmd='lmsfixfile %:p:h' direction='float'<cr>", desc = "LMS fixer this file", mode ="n"},
|
||||
-- UndoTree
|
||||
{ "<leader>u", group = "UndoTree" },
|
||||
@ -39,27 +39,27 @@ wk.add({
|
||||
{ "<leader>Z", group = "Closing"},
|
||||
{ "<leader>ZZ", "<cmd>wq!<cr>", desc = "Write en close", mode = "n"},
|
||||
{ "<leader>ZQ", "<cmd>q!<cr>", desc = "Close without write", mode = "n"},
|
||||
-- Marks
|
||||
{ "<leader>m", group = "Marks"},
|
||||
-- Creating and browsing marks
|
||||
{ "<leader>m", group = "Create / Jump mark"},
|
||||
{ "<leader>mx", marks.set, desc = "Set mark [x]", mode = "n"},
|
||||
{ "<leader>m,", marks.set_next, desc = "Set the next available alphabetical (lowercase) mark", mode = "n"},
|
||||
{ "<leader>m;", marks.toggle, desc = "Toggle the next available mark at the current line", mode = "n"},
|
||||
{ "<leader>dmx", marks.delete, desc = "Delete mark x", mode = "n"},
|
||||
{ "<leader>dm-", marks.delete_line, desc = "Delete all marks on the current line", mode = "n"},
|
||||
{ "<leader>dm<space>", marks.delete_buf, desc = "Delete all marks in the current buffer", mode = "n"},
|
||||
{ "<leader>m]", marks.next, desc = "Move to next mark", mode = "n"},
|
||||
{ "<leader>m[", marks.prev, desc = "Move to previous mark", mode = "n"},
|
||||
{ "<leader>m:", marks.preview, desc = "Preview mark. This will prompt you for a specific mark to preview; press <cr> to preview the next mark.", mode = "n"},
|
||||
{ "<leader>m[0-9]", marks.set_bookmark, desc = "Add a bookmark from bookmark group[0-9].", mode = "n"},
|
||||
{ "<leader>dm[0-9]", marks.delete_bookmark, desc = "Delete all bookmarks from bookmark group[0-9].", mode = "n"},
|
||||
{ "<leader>m}", marks.next_bookmark, desc = "Move to the next bookmark having the same type as the bookmark under the cursor. Works across buffers.", mode = "n"},
|
||||
{ "<leader>m{", marks.prev_bookmark, desc = "Move to the previous bookmark having the same type as the bookmark under the cursor. Works across buffers.", mode = "n"},
|
||||
-- Deleting marks
|
||||
{ "<leader>s", group = "Delete marks"},
|
||||
{ "<leader>dmx", marks.delete, desc = "Delete mark x", mode = "n"},
|
||||
{ "<leader>dm-", marks.delete_line, desc = "Delete all marks on the current line", mode = "n"},
|
||||
{ "<leader>dm<space>", marks.delete_buf, desc = "Delete all marks in the current buffer", mode = "n"},
|
||||
{ "<leader>dm=", marks.delete_bookmark, desc = "Delete the bookmark under the cursor.", mode = "n"},
|
||||
{ "<leader>dm[0-9]", marks.delete_bookmark, desc = "Delete all bookmarks from bookmark group[0-9].", mode = "n"},
|
||||
-- Git
|
||||
{ "<leader>h", group = "Git"},
|
||||
-- Diagnostics
|
||||
{ "<leader>h", group = "Code Diagnostics"},
|
||||
-- Diagnostics
|
||||
-- Tabs
|
||||
{ "<leader>t", group = "Tabs"},
|
||||
{ "<leader>tf", "<cmd>tabm 0<cr>", desc = "Move before first tab", mode = "n"},
|
||||
{ "<leader>tl", "<cmd>tabm<cr>", desc = "Move after last tab", mode = "n"},
|
||||
@ -77,6 +77,11 @@ wk.add({
|
||||
{ "<leader>i", group = "Indentation"},
|
||||
{ "<leader>it", "<cmd>IBLToggle<cr>", desc = "Toggle indentation guides", mode = "n"},
|
||||
{ "<leader>im", "<cmd>set list!<cr>", desc = "Toggle indentation characters", mode = "n"},
|
||||
-- Navigation
|
||||
{ "<leader>c", group = "Quick change directories"},
|
||||
{ "<leader>cr", "<cmd>cd ~/lms/<cr>", desc = "Change to lms root", mode = "n"},
|
||||
{ "<leader>cc", "<cmd>cd ~/lms/App/Lms/<cr>", desc = "Change to App/Lms", mode = "n"},
|
||||
{ "<leader>ct", "<cmd>cd ~/lms/Tests/<cr>", desc = "Change to Tests", mode = "n"},
|
||||
})
|
||||
|
||||
-- prevent using arrow keys or mouse
|
||||
|
||||
@ -43,6 +43,17 @@ vim.opt.wildignorecase = true
|
||||
-- running interactive shell commands
|
||||
vim.opt.shellcmdflag = '-ic'
|
||||
|
||||
-- system clipboard
|
||||
-- this was pretty annoying
|
||||
--vim.opt.clipboard = 'unnamedplus'
|
||||
-- folding
|
||||
vim.opt.foldmethod = 'indent'
|
||||
vim.opt.foldcolumn = '1'
|
||||
vim.opt.foldlevel = 99
|
||||
vim.opt.foldlevelstart = 99
|
||||
vim.opt.foldenable = true
|
||||
|
||||
--vim.opt.foldlevelstart=99
|
||||
--vim.opt.foldlevel=99
|
||||
--
|
||||
--vim.opt.foldmethod = 'expr'
|
||||
--vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()"
|
||||
--vim.opt.foldtext = "v:lua.vim.treesitter.foldtext()"
|
||||
|
||||
|
||||
81
lua/config/plugin/cmp.lua
Normal file
81
lua/config/plugin/cmp.lua
Normal file
@ -0,0 +1,81 @@
|
||||
-- nvim-cmp configuration with Cursor Agent completion source
|
||||
local cmp = require('cmp')
|
||||
local luasnip = require('luasnip')
|
||||
|
||||
-- Register custom Cursor completion source
|
||||
local cursor_source = require('config.cmp-cursor')
|
||||
cmp.register_source('cursor', cursor_source.new())
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||
['<Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
['<S-Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
}),
|
||||
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'cursor' }, -- Custom Cursor source (registered above)
|
||||
{ name = 'luasnip' },
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
{ name = 'path' },
|
||||
}),
|
||||
|
||||
formatting = {
|
||||
format = function(entry, vim_item)
|
||||
vim_item.menu = ({
|
||||
nvim_lsp = '[LSP]',
|
||||
cursor = '[Cursor]',
|
||||
luasnip = '[Snippet]',
|
||||
buffer = '[Buffer]',
|
||||
path = '[Path]',
|
||||
})[entry.source.name]
|
||||
return vim_item
|
||||
end,
|
||||
},
|
||||
})
|
||||
|
||||
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore)
|
||||
cmp.setup.cmdline({ '/', '?' }, {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = 'buffer' }
|
||||
}
|
||||
})
|
||||
|
||||
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore)
|
||||
cmp.setup.cmdline(':', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' }
|
||||
}, {
|
||||
{ name = 'cmdline' }
|
||||
})
|
||||
})
|
||||
@ -1,4 +1,11 @@
|
||||
local highlight = {
|
||||
"RainbowDelimiterRed",
|
||||
"RainbowDelimiterYellow",
|
||||
"RainbowDelimiterBlue",
|
||||
"RainbowDelimiterOrange",
|
||||
"RainbowDelimiterGreen",
|
||||
"RainbowDelimiterViolet",
|
||||
"RainbowDelimiterCyan",
|
||||
"RainbowRed",
|
||||
"RainbowYellow",
|
||||
"RainbowBlue",
|
||||
@ -7,18 +14,27 @@ local highlight = {
|
||||
"RainbowViolet",
|
||||
"RainbowCyan",
|
||||
}
|
||||
|
||||
local hooks = require "ibl.hooks"
|
||||
-- create the highlight groups in the highlight setup hook, so they are reset
|
||||
-- every time the colorscheme changes
|
||||
hooks.register(hooks.type.HIGHLIGHT_SETUP, function()
|
||||
vim.api.nvim_set_hl(0, "RainbowRed", { fg = "#CC241D" })
|
||||
vim.api.nvim_set_hl(0, "RainbowYellow", { fg = "#D79921" })
|
||||
vim.api.nvim_set_hl(0, "RainbowBlue", { fg = "#458588" })
|
||||
vim.api.nvim_set_hl(0, "RainbowOrange", { fg = "#D65D0E" })
|
||||
vim.api.nvim_set_hl(0, "RainbowGreen", { fg = "#98971A" })
|
||||
vim.api.nvim_set_hl(0, "RainbowViolet", { fg = "#B16286" })
|
||||
vim.api.nvim_set_hl(0, "RainbowCyan", { fg = "#689D6A" })
|
||||
vim.api.nvim_set_hl(0, "RainbowDelimiterRed", { fg = "#E06C75" })
|
||||
vim.api.nvim_set_hl(0, "RainbowDelimiterYellow", { fg = "#E5C07B" })
|
||||
vim.api.nvim_set_hl(0, "RainbowDelimiterBlue", { fg = "#61AFEF" })
|
||||
vim.api.nvim_set_hl(0, "RainbowDelimiterOrange", { fg = "#D19A66" })
|
||||
vim.api.nvim_set_hl(0, "RainbowDelimiterGreen", { fg = "#98C379" })
|
||||
vim.api.nvim_set_hl(0, "RainbowDelimiterViolet", { fg = "#C678DD" })
|
||||
vim.api.nvim_set_hl(0, "RainbowDelimiterCyan", { fg = "#56B6C2" })
|
||||
vim.api.nvim_set_hl(0, "RainbowRed", { fg = "#E06C75" })
|
||||
vim.api.nvim_set_hl(0, "RainbowYellow", { fg = "#E5C07B" })
|
||||
vim.api.nvim_set_hl(0, "RainbowBlue", { fg = "#61AFEF" })
|
||||
vim.api.nvim_set_hl(0, "RainbowOrange", { fg = "#D19A66" })
|
||||
vim.api.nvim_set_hl(0, "RainbowGreen", { fg = "#98C379" })
|
||||
vim.api.nvim_set_hl(0, "RainbowViolet", { fg = "#C678DD" })
|
||||
vim.api.nvim_set_hl(0, "RainbowCyan", { fg = "#56B6C2" })
|
||||
end)
|
||||
|
||||
require("ibl").setup { indent = { highlight = highlight } }
|
||||
vim.g.rainbow_delimiters = { highlight = highlight }
|
||||
require("ibl").setup { scope = { highlight = highlight } }
|
||||
|
||||
hooks.register(hooks.type.SCOPE_HIGHLIGHT, hooks.builtin.scope_highlight_from_extmark)
|
||||
|
||||
@ -8,10 +8,11 @@ require("config.plugin.vim-gitgutter")
|
||||
require("config.plugin.deadcolumn")
|
||||
require("config.plugin.colorizer")
|
||||
require("config.plugin.synattr")
|
||||
require("config.plugin.rainbow-delimiters")
|
||||
require("config.plugin.marks")
|
||||
require("config.plugin.vim-indentwise")
|
||||
require("config.plugin.rainbow-delimiters")
|
||||
require("config.plugin.indent-blankline")
|
||||
require("config.plugin.scrollbar")
|
||||
require("config.plugin.lspsaga")
|
||||
require("config.plugin.gruvbox")
|
||||
require("config.plugin.cmp")
|
||||
|
||||
@ -1,15 +1,40 @@
|
||||
-- This module contains a number of default definitions
|
||||
local rainbow_delimiters = require 'rainbow-delimiters'
|
||||
|
||||
--vim.g.rainbow_delimiters = {
|
||||
-- strategy = {
|
||||
-- [''] = rainbow_delimiters.strategy['global'],
|
||||
-- commonlisp = rainbow_delimiters.strategy['local'],
|
||||
-- },
|
||||
-- query = {
|
||||
-- [''] = 'rainbow-delimiters',
|
||||
-- lua = 'rainbow-blocks',
|
||||
-- },
|
||||
-- --highlight = {
|
||||
-- -- 'RainbowRed',
|
||||
-- -- 'RainbowYellow',
|
||||
-- -- 'RainbowBlue',
|
||||
-- -- 'RainbowOrange',
|
||||
-- -- 'RainbowGreen',
|
||||
-- -- 'RainbowViolet',
|
||||
-- -- 'RainbowCyan',
|
||||
-- --},
|
||||
-- blacklist = {'c', 'cpp'},
|
||||
--}
|
||||
|
||||
vim.g.rainbow_delimiters = {
|
||||
strategy = {
|
||||
[''] = rainbow_delimiters.strategy['global'],
|
||||
commonlisp = rainbow_delimiters.strategy['local'],
|
||||
[''] = 'rainbow-delimiters.strategy.global',
|
||||
vim = 'rainbow-delimiters.strategy.local',
|
||||
},
|
||||
query = {
|
||||
[''] = 'rainbow-delimiters',
|
||||
lua = 'rainbow-blocks',
|
||||
},
|
||||
priority = {
|
||||
[''] = 110,
|
||||
lua = 210,
|
||||
},
|
||||
highlight = {
|
||||
'RainbowDelimiterRed',
|
||||
'RainbowDelimiterYellow',
|
||||
@ -19,6 +44,4 @@ vim.g.rainbow_delimiters = {
|
||||
'RainbowDelimiterViolet',
|
||||
'RainbowDelimiterCyan',
|
||||
},
|
||||
blacklist = {'c', 'cpp'},
|
||||
}
|
||||
|
||||
|
||||
@ -196,6 +196,21 @@ return {
|
||||
version = "*",
|
||||
config = true
|
||||
},
|
||||
-- Completion framework
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-path",
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-cmdline",
|
||||
"L3MON4D3/LuaSnip",
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
},
|
||||
config = function()
|
||||
require("config.plugin.cmp")
|
||||
end,
|
||||
},
|
||||
-- AI
|
||||
-- {
|
||||
-- "supermaven-inc/supermaven-nvim",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user