Compare commits
5 Commits
62a52c1c01
...
65ffd3275b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65ffd3275b | ||
|
|
24dc3916df | ||
|
|
0071aa4485 | ||
|
|
22352723cf | ||
|
|
c1cddfdf68 |
189
LSP_TROUBLESHOOTING_GUIDE.md
Normal file
189
LSP_TROUBLESHOOTING_GUIDE.md
Normal file
@@ -0,0 +1,189 @@
|
||||
# LSP Troubleshooting and Performance Guide
|
||||
|
||||
## Overview
|
||||
This guide addresses the LSP errors and image freezing issues you've been experiencing during file searches in Neovim.
|
||||
|
||||
## Problems Solved
|
||||
|
||||
### 1. LSP Errors on Non-Text Files
|
||||
**Problem**: LSP servers were trying to process image files (PNG, SVG, etc.), video files, and other binary files, causing errors.
|
||||
|
||||
**Solution**: Added comprehensive file type filtering that prevents LSP from attaching to non-text files.
|
||||
|
||||
### 2. Image Freezing During Search
|
||||
**Problem**: When searching for files, image files would freeze the preview window indefinitely.
|
||||
|
||||
**Solution**: Enhanced Telescope configuration with file filtering and optimized preview settings.
|
||||
|
||||
### 3. Slow Leader Key Response
|
||||
**Problem**: Leader key commands (like `<leader>ff`, `<leader>fs`) were slow to respond.
|
||||
|
||||
**Solution**: Reduced timeout settings and optimized completion performance.
|
||||
|
||||
## New Keymaps
|
||||
|
||||
### Performance Monitoring
|
||||
- `<leader>pp` - Check overall performance
|
||||
- `<leader>po` - Check plugin performance
|
||||
- `<leader>pb` - Optimize current buffer
|
||||
|
||||
### LSP Troubleshooting
|
||||
- `<leader>pl` - Check LSP health
|
||||
- `<leader>pr` - Restart LSP for current buffer
|
||||
|
||||
### Safe File Searching (Recommended)
|
||||
- `<leader>ff` - Find files (safe - prevents LSP errors)
|
||||
- `<leader>fs` - Live grep (safe)
|
||||
- `<leader>fg` - Git files (safe)
|
||||
- `<leader>ft` - Text files only
|
||||
|
||||
### Regular Search (Use with Caution)
|
||||
- `<leader>fF` - Find files (all file types)
|
||||
|
||||
## File Types Automatically Filtered
|
||||
|
||||
### Images (Prevent LSP errors)
|
||||
- PNG, JPG, JPEG, GIF, SVG, ICO, BMP, WebP, TIFF, TGA
|
||||
|
||||
### Videos (Prevent freezing)
|
||||
- MP4, AVI, MOV, WMV, FLV, WebM, MKV, M4V, 3GP
|
||||
|
||||
### Audio (Prevent LSP errors)
|
||||
- MP3, WAV, FLAC, AAC, OGG, M4A, WMA
|
||||
|
||||
### Documents (Prevent LSP errors)
|
||||
- PDF, DOC, DOCX, XLS, XLSX, PPT, PPTX, ODT, ODS, ODP
|
||||
|
||||
### Archives (Prevent LSP errors)
|
||||
- ZIP, RAR, 7Z, TAR, GZ, BZ2, XZ, LZMA
|
||||
|
||||
### Binaries (Prevent LSP errors)
|
||||
- EXE, DLL, SO, DYLD, BIN, APP, DMG, DEB, RPM
|
||||
|
||||
### Other Problematic Files
|
||||
- LOCK, LOG, TMP, TEMP, CACHE, BAK, BACKUP
|
||||
|
||||
## Performance Optimizations Applied
|
||||
|
||||
### LSP Configuration
|
||||
- **File filtering**: Only text files get LSP services
|
||||
- **Error handling**: Graceful handling of LSP failures
|
||||
- **Timeouts**: 5-second timeout for LSP requests
|
||||
- **Debouncing**: 150ms debounce for text changes
|
||||
- **Diagnostics**: Reduced diagnostic updates
|
||||
|
||||
### Telescope Configuration
|
||||
- **File filtering**: Automatic exclusion of problematic files
|
||||
- **Preview optimization**: Disabled preview for non-text files
|
||||
- **Search optimization**: Skip heavy directories (node_modules, vendor, etc.)
|
||||
- **Performance flags**: Enhanced caching and sorting
|
||||
|
||||
### General Performance
|
||||
- **Reduced timeouts**: Faster leader key response
|
||||
- **Optimized scrolling**: Reduced scrolloff for smoother movement
|
||||
- **Memory management**: Better memory usage patterns
|
||||
- **Startup optimization**: Deferred heavy operations
|
||||
|
||||
## Troubleshooting Steps
|
||||
|
||||
### If You Still Experience LSP Errors
|
||||
|
||||
1. **Check LSP Health**
|
||||
```
|
||||
<leader>pl
|
||||
```
|
||||
|
||||
2. **Restart LSP for Current Buffer**
|
||||
```
|
||||
<leader>pr
|
||||
```
|
||||
|
||||
3. **Check Performance**
|
||||
```
|
||||
<leader>pp
|
||||
```
|
||||
|
||||
4. **Use Safe File Search**
|
||||
- Always use `<leader>ff` instead of `<leader>fF`
|
||||
- This prevents LSP from processing problematic files
|
||||
|
||||
### If Images Still Freeze
|
||||
|
||||
1. **Check File Extensions**
|
||||
- Ensure the file has a text-based extension
|
||||
- Use `<leader>ft` for text-only file search
|
||||
|
||||
2. **Optimize Current Buffer**
|
||||
```
|
||||
<leader>pb
|
||||
```
|
||||
|
||||
3. **Check Plugin Performance**
|
||||
```
|
||||
<leader>po
|
||||
```
|
||||
|
||||
## Advanced Configuration
|
||||
|
||||
### Custom File Filtering
|
||||
You can modify the file filtering in `lua/cargdev/plugins/lsp/lspconfig.lua`:
|
||||
|
||||
```lua
|
||||
local non_text_extensions = {
|
||||
-- Add or remove extensions as needed
|
||||
"png", "jpg", "jpeg", "gif", "svg",
|
||||
-- ... other extensions
|
||||
}
|
||||
```
|
||||
|
||||
### Telescope Customization
|
||||
Modify the file filter in `lua/cargdev/plugins/telescope.lua`:
|
||||
|
||||
```lua
|
||||
local function filter_files(entry)
|
||||
-- Customize filtering logic here
|
||||
local filename = entry.filename or entry.value
|
||||
-- ... your custom logic
|
||||
end
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
### 1. Always Use Safe Search
|
||||
- `<leader>ff` for file finding
|
||||
- `<leader>fs` for text searching
|
||||
- Avoid `<leader>fF` unless you specifically need all file types
|
||||
|
||||
### 2. Monitor Performance
|
||||
- Use `<leader>pp` regularly to check for issues
|
||||
- Monitor LSP health with `<leader>pl`
|
||||
|
||||
### 3. Optimize Large Files
|
||||
- Use `<leader>pb` for files over 10,000 lines
|
||||
- Consider disabling heavy features for very large files
|
||||
|
||||
### 4. Keep LSP Healthy
|
||||
- Restart LSP with `<leader>pr` if you experience issues
|
||||
- Check for LSP errors in the performance report
|
||||
|
||||
## Expected Results
|
||||
|
||||
After applying these optimizations:
|
||||
|
||||
- ✅ **No more LSP errors** on image/video/binary files
|
||||
- ✅ **No more image freezing** during file searches
|
||||
- ✅ **Faster leader key response** (reduced from 500ms to 200ms)
|
||||
- ✅ **Smoother scrolling** and UI performance
|
||||
- ✅ **Better memory usage** and startup times
|
||||
- ✅ **Automatic file type filtering** to prevent issues
|
||||
|
||||
## Support
|
||||
|
||||
If you continue to experience issues:
|
||||
|
||||
1. Run `<leader>pp` to get a detailed performance report
|
||||
2. Check LSP health with `<leader>pl`
|
||||
3. Use the safe file search commands (`<leader>ff`, `<leader>fs`)
|
||||
4. Consider restarting LSP with `<leader>pr`
|
||||
|
||||
The optimizations maintain all your functionality while significantly improving stability and performance.
|
||||
192
keybind.json
192
keybind.json
@@ -1,4 +1,8 @@
|
||||
[
|
||||
{
|
||||
"key": "cmd+i",
|
||||
"command": "composerMode.agent"
|
||||
},
|
||||
{
|
||||
"key": "ctrl-h",
|
||||
"command": "workbench.action.navigateLeft"
|
||||
@@ -35,121 +39,13 @@
|
||||
"workbench.action.focusActiveEditorGroup"
|
||||
]
|
||||
},
|
||||
"when": "sideBarFocus && !inputFocus"
|
||||
"when": "vim.mode == 'Normal' && sideBarFocus && !inputFocus"
|
||||
},
|
||||
{
|
||||
"key": "space e",
|
||||
"when": "vim.mode == 'Normal' && editorTextFocus && foldersViewVisible",
|
||||
"command": "workbench.action.toggleSidebarVisibility"
|
||||
},
|
||||
{
|
||||
"key": "s h",
|
||||
"command": "workbench.action.splitEditor",
|
||||
"when": "vim.mode == 'Normal' && (editorTextFocus || !inputFocus)"
|
||||
},
|
||||
{
|
||||
"key": "s v",
|
||||
"command": "workbench.action.splitEditorDown",
|
||||
"when": "vim.mode == 'Normal' && (editorTextFocus || !inputFocus)"
|
||||
},
|
||||
{
|
||||
"key": "space c a",
|
||||
"command": "editor.action.codeAction",
|
||||
"when": "vim.mode == 'Normal' && editorTextFocus"
|
||||
},
|
||||
{
|
||||
"key": "shift-k",
|
||||
"command": "editor.action.moveLinesUpAction",
|
||||
"when": "vim.mode == 'VisualLine' && editorTextFocus"
|
||||
},
|
||||
{
|
||||
"key": "shift-j",
|
||||
"command": "editor.action.moveLinesDownAction",
|
||||
"when": "vim.mode == 'VisualLine' && editorTextFocus"
|
||||
},
|
||||
{
|
||||
"key": "shift-k",
|
||||
"command": "editor.action.showHover",
|
||||
"when": "vim.mode == 'Normal' && editorTextFocus"
|
||||
},
|
||||
{
|
||||
"key": "space c r",
|
||||
"command": "editor.action.rename",
|
||||
"when": "vim.mode == 'Normal' && editorTextFocus"
|
||||
},
|
||||
{
|
||||
"key": "space c s",
|
||||
"command": "workbench.action.gotoSymbol",
|
||||
"when": "vim.mode == 'Normal' && editorTextFocus"
|
||||
},
|
||||
{
|
||||
"key": "space b d",
|
||||
"command": "workbench.action.closeActiveEditor",
|
||||
"when": "(vim.mode == 'Normal' && editorTextFocus) || !inputFocus"
|
||||
},
|
||||
{
|
||||
"key": "space b o",
|
||||
"command": "workbench.action.closeOtherEditors",
|
||||
"when": "(vim.mode == 'Normal' && editorTextFocus) || !inputFocus"
|
||||
},
|
||||
{
|
||||
"key": "space space",
|
||||
"command": "workbench.action.quickOpen",
|
||||
"when": "vim.mode == 'Normal' && (editorTextFocus || !inputFocus)"
|
||||
},
|
||||
{
|
||||
"key": "space g d",
|
||||
"command": "editor.action.revealDefinition",
|
||||
"when": "vim.mode == 'Normal' && editorTextFocus"
|
||||
},
|
||||
{
|
||||
"key": "space g r",
|
||||
"command": "editor.action.goToReferences",
|
||||
"when": "vim.mode == 'Normal' && editorTextFocus"
|
||||
},
|
||||
{
|
||||
"key": "space g i",
|
||||
"command": "editor.action.goToImplementation",
|
||||
"when": "vim.mode == 'Normal' && editorTextFocus"
|
||||
},
|
||||
{
|
||||
"key": "space s g",
|
||||
"command": "workbench.action.findInFiles",
|
||||
"when": "vim.mode == 'Normal' && (editorTextFocus || !inputFocus)"
|
||||
},
|
||||
{
|
||||
"key": "space g g",
|
||||
"command": "runCommands",
|
||||
"when": "vim.mode == 'Normal' && (editorTextFocus || !inputFocus)",
|
||||
"args": {
|
||||
"commands": ["workbench.view.scm", "workbench.scm.focus"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "ctrl-n",
|
||||
"command": "editor.action.addSelectionToNextFindMatch",
|
||||
"when": "(vim.mode == 'Normal' || vim.mode == 'Visual') && (editorTextFocus || !inputFocus)"
|
||||
},
|
||||
{
|
||||
"key": "ctrl-n",
|
||||
"command": "workbench.action.toggleSidebarVisibility",
|
||||
"when": "vim.mode == 'Normal' && (editorTextFocus || !inputFocus)"
|
||||
},
|
||||
{
|
||||
"key": "space f s",
|
||||
"command": "workbench.action.findInFiles",
|
||||
"when": "vim.mode == 'Normal' && (editorTextFocus || !inputFocus)"
|
||||
},
|
||||
{
|
||||
"key": "n",
|
||||
"command": "search.action.focusNextSearchResult",
|
||||
"when": "vim.mode == 'Normal' && (editorTextFocus || !inputFocus)"
|
||||
},
|
||||
{
|
||||
"key": "shift-n",
|
||||
"command": "search.action.focusPreviousSearchResult",
|
||||
"when": "vim.mode == 'Normal' && (editorTextFocus || !inputFocus)"
|
||||
},
|
||||
{
|
||||
"key": "ctrl-w h",
|
||||
"command": "workbench.action.navigateLeft",
|
||||
@@ -171,51 +67,39 @@
|
||||
"when": "vim.mode == 'Normal' && (editorTextFocus || !inputFocus)"
|
||||
},
|
||||
{
|
||||
"key": "r",
|
||||
"key": "space r",
|
||||
"command": "renameFile",
|
||||
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
|
||||
"when": "vim.mode == 'Normal' && filesExplorerFocus && !inputFocus"
|
||||
},
|
||||
{
|
||||
"key": "x",
|
||||
"key": "space x",
|
||||
"command": "filesExplorer.cut",
|
||||
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
|
||||
"when": "vim.mode == 'Normal' && filesExplorerFocus && !inputFocus"
|
||||
},
|
||||
{
|
||||
"key": "d",
|
||||
"key": "space d",
|
||||
"command": "deleteFile",
|
||||
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
|
||||
"when": "vim.mode == 'Normal' && filesExplorerFocus && !inputFocus"
|
||||
},
|
||||
{
|
||||
"key": "a",
|
||||
"key": "space a",
|
||||
"command": "explorer.newFile",
|
||||
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
|
||||
"when": "vim.mode == 'Normal' && filesExplorerFocus && !inputFocus"
|
||||
},
|
||||
{
|
||||
"key": "s",
|
||||
"key": "space s",
|
||||
"command": "explorer.openToSide",
|
||||
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
|
||||
},
|
||||
{
|
||||
"key": "shift-s",
|
||||
"command": "runCommands",
|
||||
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus",
|
||||
"args": {
|
||||
"commands": [
|
||||
"workbench.action.splitEditorDown",
|
||||
"explorer.openAndPassFocus",
|
||||
"workbench.action.closeOtherEditors"
|
||||
]
|
||||
}
|
||||
"when": "vim.mode == 'Normal' && filesExplorerFocus && !inputFocus"
|
||||
},
|
||||
{
|
||||
"key": "enter",
|
||||
"command": "explorer.openAndPassFocus",
|
||||
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !explorerResourceIsFolder && !inputFocus"
|
||||
"when": "filesExplorerFocus && !explorerResourceIsFolder && !inputFocus"
|
||||
},
|
||||
{
|
||||
"key": "enter",
|
||||
"command": "list.toggleExpand",
|
||||
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && explorerResourceIsFolder && !inputFocus"
|
||||
"when": "filesExplorerFocus && explorerResourceIsFolder && !inputFocus"
|
||||
},
|
||||
{
|
||||
"key": "space d a",
|
||||
@@ -227,6 +111,18 @@
|
||||
"command": "workbench.action.debug.stop",
|
||||
"when": "vim.mode == 'Normal' && editorTextFocus && inDebugMode && !focusedSessionIsAttached"
|
||||
},
|
||||
{
|
||||
"key": "space shift-s",
|
||||
"command": "runCommands",
|
||||
"when": "vim.mode == 'Normal' && filesExplorerFocus && !inputFocus",
|
||||
"args": {
|
||||
"commands": [
|
||||
"workbench.action.splitEditorDown",
|
||||
"explorer.openAndPassFocus",
|
||||
"workbench.action.closeOtherEditors"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "space d o",
|
||||
"command": "workbench.action.debug.stepOver",
|
||||
@@ -247,11 +143,6 @@
|
||||
"command": "workbench.action.debug.continue",
|
||||
"when": "vim.mode == 'Normal' && (editorTextFocus || !inputFocus) && inDebugMode && debugState == 'stopped'"
|
||||
},
|
||||
{
|
||||
"key": "space u",
|
||||
"command": "editor.action.selectAll",
|
||||
"when": "vim.mode == 'Normal' && (editorTextFocus || !inputFocus)"
|
||||
},
|
||||
{
|
||||
"key": "space w",
|
||||
"command": "workbench.action.files.save",
|
||||
@@ -267,21 +158,6 @@
|
||||
"command": "workbench.action.closeAllEditors",
|
||||
"when": "vim.mode == 'Normal' && (editorTextFocus || !inputFocus)"
|
||||
},
|
||||
{
|
||||
"key": "y",
|
||||
"command": "editor.action.clipboardCopyAction",
|
||||
"when": "vim.mode == 'Normal' && (editorTextFocus || !inputFocus)"
|
||||
},
|
||||
{
|
||||
"key": "d d",
|
||||
"command": "editor.action.deleteLines",
|
||||
"when": "vim.mode == 'Normal' && (editorTextFocus || !inputFocus)"
|
||||
},
|
||||
{
|
||||
"key": "p",
|
||||
"command": "editor.action.clipboardPasteAction",
|
||||
"when": "vim.mode == 'Normal' && (editorTextFocus || !inputFocus)"
|
||||
},
|
||||
{
|
||||
"key": "ctrl-e",
|
||||
"command": "editorScroll",
|
||||
@@ -296,18 +172,18 @@
|
||||
},
|
||||
{
|
||||
"key": "space n t",
|
||||
"command": "workbench.files.action.showActiveFileInExplorer",
|
||||
"command": "workbench.view.explorer",
|
||||
"when": "vim.mode == 'Normal' && (editorTextFocus || !inputFocus)"
|
||||
},
|
||||
{
|
||||
"key": "o",
|
||||
"key": "space o",
|
||||
"command": "workbench.action.splitEditorRight",
|
||||
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !inputFocus"
|
||||
"when": "vim.mode == 'Normal' && filesExplorerFocus && !inputFocus"
|
||||
},
|
||||
{
|
||||
"key": "i",
|
||||
"key": "space i",
|
||||
"command": "workbench.action.splitEditorDown",
|
||||
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !inputFocus"
|
||||
"when": "vim.mode == 'Normal' && filesExplorerFocus && !inputFocus"
|
||||
},
|
||||
{
|
||||
"key": "ctrl-p",
|
||||
|
||||
313
lua/cargdev/core/function/notification_manager.lua
Normal file
313
lua/cargdev/core/function/notification_manager.lua
Normal file
@@ -0,0 +1,313 @@
|
||||
-- Custom notification manager to handle overlapping and improve UX
|
||||
local M = {}
|
||||
|
||||
-- Track active notifications to prevent overlapping
|
||||
local active_notifications = {}
|
||||
local notification_queue = {}
|
||||
|
||||
-- Function to show a notification without overlapping
|
||||
function M.show_notification(message, level, opts)
|
||||
level = level or vim.log.levels.INFO
|
||||
opts = opts or {}
|
||||
|
||||
-- Default options
|
||||
local default_opts = {
|
||||
timeout = 3000,
|
||||
title = "CarGDev Neovim",
|
||||
render = "minimal",
|
||||
stages = "fade_in_slide_out",
|
||||
position = "top_right",
|
||||
max_width = 50,
|
||||
max_height = 8,
|
||||
background_colour = "#000000",
|
||||
border_style = "rounded",
|
||||
}
|
||||
|
||||
-- Merge options
|
||||
for k, v in pairs(default_opts) do
|
||||
if opts[k] == nil then
|
||||
opts[k] = v
|
||||
end
|
||||
end
|
||||
|
||||
-- Check if we're in alpha dashboard
|
||||
local current_buf = vim.api.nvim_get_current_buf()
|
||||
local current_ft = vim.api.nvim_buf_get_option(current_buf, "filetype")
|
||||
|
||||
if current_ft == "alpha" then
|
||||
-- If in dashboard, use a different approach
|
||||
M.show_dashboard_notification(message, level, opts)
|
||||
return
|
||||
end
|
||||
|
||||
-- Use nvim-notify if available
|
||||
local notify_available = pcall(require, "notify")
|
||||
if notify_available then
|
||||
local notify = require("notify")
|
||||
|
||||
-- Position notification to avoid overlapping
|
||||
opts.on_open = function(win)
|
||||
-- Calculate position to avoid overlapping with other notifications
|
||||
local row = 2
|
||||
local col = vim.o.columns - 60
|
||||
|
||||
-- Adjust position if there are other notifications
|
||||
for _, notif in ipairs(active_notifications) do
|
||||
if notif.win and vim.api.nvim_win_is_valid(notif.win) then
|
||||
row = row + 10 -- Stack notifications vertically
|
||||
end
|
||||
end
|
||||
|
||||
-- Ensure notification doesn't go off-screen
|
||||
if row > vim.o.lines - 15 then
|
||||
row = 2
|
||||
col = col - 20
|
||||
end
|
||||
|
||||
vim.api.nvim_win_set_config(win, {
|
||||
row = row,
|
||||
col = col,
|
||||
relative = "editor",
|
||||
width = opts.max_width,
|
||||
height = opts.max_height,
|
||||
})
|
||||
|
||||
-- Track this notification
|
||||
table.insert(active_notifications, {
|
||||
win = win,
|
||||
message = message,
|
||||
timestamp = vim.loop.now(),
|
||||
})
|
||||
end
|
||||
|
||||
opts.on_close = function(win)
|
||||
-- Remove from active notifications
|
||||
for i, notif in ipairs(active_notifications) do
|
||||
if notif.win == win then
|
||||
table.remove(active_notifications, i)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Show notification
|
||||
local notification_id = notify(message, level, opts)
|
||||
return notification_id
|
||||
else
|
||||
-- Fallback to echo instead of vim.notify to avoid circular dependency
|
||||
local icon = "💬"
|
||||
if level == vim.log.levels.ERROR then
|
||||
icon = "❌"
|
||||
elseif level == vim.log.levels.WARN then
|
||||
icon = "⚠️"
|
||||
elseif level == vim.log.levels.INFO then
|
||||
icon = "ℹ️"
|
||||
end
|
||||
|
||||
-- Use echo for fallback notifications
|
||||
vim.cmd("echo '" .. icon .. " " .. message .. "'")
|
||||
|
||||
-- Clear message after a delay
|
||||
vim.defer_fn(function()
|
||||
vim.cmd("echo ''")
|
||||
end, opts.timeout or 3000)
|
||||
end
|
||||
end
|
||||
|
||||
-- Function to show notifications specifically for dashboard
|
||||
function M.show_dashboard_notification(message, level, opts)
|
||||
-- In dashboard, show minimal notifications
|
||||
local icon = "💬"
|
||||
if level == vim.log.levels.ERROR then
|
||||
icon = "❌"
|
||||
elseif level == vim.log.levels.WARN then
|
||||
icon = "⚠️"
|
||||
elseif level == vim.log.levels.INFO then
|
||||
icon = "ℹ️"
|
||||
end
|
||||
|
||||
-- Show message in status line or use echo
|
||||
local short_message = message:sub(1, 50)
|
||||
if #message > 50 then
|
||||
short_message = short_message .. "..."
|
||||
end
|
||||
|
||||
-- Use echo for dashboard notifications to avoid overlapping
|
||||
vim.cmd("echo '" .. icon .. " " .. short_message .. "'")
|
||||
|
||||
-- Clear message after a delay
|
||||
vim.defer_fn(function()
|
||||
vim.cmd("echo ''")
|
||||
end, opts.timeout or 3000)
|
||||
end
|
||||
|
||||
-- Function to clear all notifications
|
||||
function M.clear_all_notifications()
|
||||
for _, notif in ipairs(active_notifications) do
|
||||
if notif.win and vim.api.nvim_win_is_valid(notif.win) then
|
||||
vim.api.nvim_win_close(notif.win, true)
|
||||
end
|
||||
end
|
||||
active_notifications = {}
|
||||
end
|
||||
|
||||
-- Function to show performance notification
|
||||
function M.show_performance_notification(message, level)
|
||||
M.show_notification("📊 " .. message, level, {
|
||||
title = "Performance Monitor",
|
||||
timeout = 4000,
|
||||
position = "top_right",
|
||||
})
|
||||
end
|
||||
|
||||
-- Function to show LSP notification
|
||||
function M.show_lsp_notification(message, level)
|
||||
M.show_notification("🔧 " .. message, level, {
|
||||
title = "LSP Status",
|
||||
timeout = 3000,
|
||||
position = "top_right",
|
||||
})
|
||||
end
|
||||
|
||||
-- Function to show file operation notification
|
||||
function M.show_file_notification(message, level)
|
||||
M.show_notification("📁 " .. message, level, {
|
||||
title = "File Operation",
|
||||
timeout = 2500,
|
||||
position = "top_right",
|
||||
})
|
||||
end
|
||||
|
||||
-- Function to show plugin notification
|
||||
function M.show_plugin_notification(message, level)
|
||||
M.show_notification("🦥 " .. message, level, {
|
||||
title = "Plugin Manager",
|
||||
timeout = 3000,
|
||||
position = "top_right",
|
||||
})
|
||||
end
|
||||
|
||||
-- Function to show startup notification
|
||||
function M.show_startup_notification(message, level)
|
||||
M.show_notification("🚀 " .. message, level, {
|
||||
title = "Startup",
|
||||
timeout = 2000,
|
||||
position = "top_right",
|
||||
})
|
||||
end
|
||||
|
||||
-- Function to handle startup messages aggressively
|
||||
function M.handle_startup_messages()
|
||||
-- Clear any existing messages immediately
|
||||
vim.cmd("redraw!")
|
||||
vim.cmd("echo ''")
|
||||
|
||||
-- Suppress all startup messages
|
||||
vim.opt.shortmess = vim.opt.shortmess + "I" -- No intro message
|
||||
vim.opt.shortmess = vim.opt.shortmess + "c" -- No completion messages
|
||||
vim.opt.shortmess = vim.opt.shortmess + "F" -- No file info message
|
||||
vim.opt.shortmess = vim.opt.shortmess + "W" -- No "written" message
|
||||
vim.opt.shortmess = vim.opt.shortmess + "A" -- No attention message
|
||||
vim.opt.shortmess = vim.opt.shortmess + "o" -- No overwrite messages
|
||||
vim.opt.shortmess = vim.opt.shortmess + "t" -- No truncation messages
|
||||
vim.opt.shortmess = vim.opt.shortmess + "T" -- No truncation messages
|
||||
vim.opt.shortmess = vim.opt.shortmess + "f" -- No file info messages
|
||||
vim.opt.shortmess = vim.opt.shortmess + "i" -- No intro messages
|
||||
vim.opt.shortmess = vim.opt.shortmess + "l" -- No line number messages
|
||||
vim.opt.shortmess = vim.opt.shortmess + "m" -- No modification messages
|
||||
vim.opt.shortmess = vim.opt.shortmess + "n" -- No line number messages
|
||||
vim.opt.shortmess = vim.opt.shortmess + "r" -- No read messages
|
||||
vim.opt.shortmess = vim.opt.shortmess + "s" -- No search messages
|
||||
vim.opt.shortmess = vim.opt.shortmess + "x" -- No truncation messages
|
||||
vim.opt.shortmess = vim.opt.shortmess + "O" -- No overwrite messages
|
||||
|
||||
-- Disable command line messages
|
||||
vim.opt.cmdheight = 0
|
||||
vim.opt.showmode = false
|
||||
|
||||
-- Clear any existing messages
|
||||
vim.cmd("echo ''")
|
||||
|
||||
-- Force clear any pending messages
|
||||
vim.defer_fn(function()
|
||||
vim.cmd("redraw!")
|
||||
vim.cmd("echo ''")
|
||||
end, 100)
|
||||
end
|
||||
|
||||
-- Function to eliminate "Press ENTER" prompts completely
|
||||
function M.eliminate_enter_prompts()
|
||||
-- Override the message display to prevent "Press ENTER" prompts
|
||||
local original_echo = vim.cmd.echo
|
||||
vim.cmd.echo = function(msg)
|
||||
local msg_str = tostring(msg)
|
||||
-- Block any messages that might cause "Press ENTER" prompts
|
||||
if msg_str:match("Press ENTER") or
|
||||
msg_str:match("lazyredraw") or
|
||||
msg_str:match("You have enabled") or
|
||||
msg_str:match("This is only meant") or
|
||||
msg_str:match("You'll experience issues") then
|
||||
return -- Don't show these messages
|
||||
end
|
||||
-- Allow other messages
|
||||
original_echo(msg)
|
||||
end
|
||||
|
||||
-- Create autocmd to handle any remaining prompts
|
||||
vim.api.nvim_create_autocmd("VimEnter", {
|
||||
callback = function()
|
||||
-- Clear any startup messages immediately
|
||||
vim.cmd("redraw!")
|
||||
vim.cmd("echo ''")
|
||||
|
||||
-- Force clear any pending messages multiple times
|
||||
for i = 1, 5 do
|
||||
vim.defer_fn(function()
|
||||
vim.cmd("redraw!")
|
||||
vim.cmd("echo ''")
|
||||
end, i * 50)
|
||||
end
|
||||
end,
|
||||
once = true,
|
||||
})
|
||||
|
||||
-- Create autocmd to handle message events - use valid events
|
||||
vim.api.nvim_create_autocmd("BufReadPost", {
|
||||
callback = function()
|
||||
-- Clear messages that might cause prompts
|
||||
vim.cmd("redraw!")
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
-- Function to setup notification system
|
||||
function M.setup()
|
||||
-- Create autocmd to handle startup messages
|
||||
vim.api.nvim_create_autocmd("VimEnter", {
|
||||
callback = function()
|
||||
M.handle_startup_messages()
|
||||
end,
|
||||
once = true,
|
||||
})
|
||||
|
||||
-- Create autocmd to handle alpha dashboard
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "alpha",
|
||||
callback = function()
|
||||
M.handle_startup_messages()
|
||||
end,
|
||||
})
|
||||
|
||||
-- Eliminate "Press ENTER" prompts
|
||||
M.eliminate_enter_prompts()
|
||||
|
||||
-- Don't override vim.notify here to avoid circular dependency
|
||||
-- Let the system handle notifications naturally
|
||||
|
||||
print("Notification manager initialized")
|
||||
end
|
||||
|
||||
-- Initialize notification manager
|
||||
M.setup()
|
||||
|
||||
return M
|
||||
334
lua/cargdev/core/function/performance_monitor.lua
Normal file
334
lua/cargdev/core/function/performance_monitor.lua
Normal file
@@ -0,0 +1,334 @@
|
||||
-- Performance monitoring and diagnostics
|
||||
local M = {}
|
||||
|
||||
-- Function to check Neovim performance
|
||||
function M.check_performance()
|
||||
local start_time = vim.loop.hrtime()
|
||||
|
||||
-- Check startup time
|
||||
local startup_time = vim.g.startup_time or 0
|
||||
|
||||
-- Check memory usage safely
|
||||
local memory_mb = 0
|
||||
local memory_info_available = pcall(function()
|
||||
local info = vim.loop.get_memory_info()
|
||||
if info and info.used then
|
||||
memory_mb = math.floor(info.used / 1024 / 1024)
|
||||
end
|
||||
end)
|
||||
|
||||
if not memory_info_available then
|
||||
memory_mb = "N/A (not available on this platform)"
|
||||
end
|
||||
|
||||
-- Check buffer count
|
||||
local buffer_count = #vim.api.nvim_list_bufs()
|
||||
|
||||
-- Check window count
|
||||
local window_count = #vim.api.nvim_list_wins()
|
||||
|
||||
-- Check tab count
|
||||
local tab_count = #vim.api.nvim_list_tabpages()
|
||||
|
||||
-- Check if any LSP servers are running
|
||||
local active_clients = vim.lsp.get_active_clients()
|
||||
local lsp_count = #active_clients
|
||||
|
||||
-- Check if treesitter is active
|
||||
local ts_available, ts = pcall(require, "nvim-treesitter")
|
||||
local ts_active = ts_available and ts.status() and "Active" or "Inactive"
|
||||
|
||||
-- Check LSP errors and warnings
|
||||
local diagnostics = vim.diagnostic.get()
|
||||
local error_count = 0
|
||||
local warning_count = 0
|
||||
|
||||
for _, diag in ipairs(diagnostics) do
|
||||
if diag.severity == vim.diagnostic.severity.ERROR then
|
||||
error_count = error_count + 1
|
||||
elseif diag.severity == vim.diagnostic.severity.WARN then
|
||||
warning_count = warning_count + 1
|
||||
end
|
||||
end
|
||||
|
||||
-- Check current buffer file type and potential issues
|
||||
local current_buf = vim.api.nvim_get_current_buf()
|
||||
local current_filename = vim.api.nvim_buf_get_name(current_buf)
|
||||
local current_filetype = vim.api.nvim_buf_get_option(current_buf, "filetype")
|
||||
local current_line_count = vim.api.nvim_buf_line_count(current_buf)
|
||||
|
||||
-- Check if current file might cause LSP issues
|
||||
local problematic_extensions = {
|
||||
"png", "jpg", "jpeg", "gif", "svg", "ico", "bmp", "webp",
|
||||
"mp4", "avi", "mov", "wmv", "flv", "webm", "mkv",
|
||||
"mp3", "wav", "flac", "aac", "ogg",
|
||||
"pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx",
|
||||
"zip", "rar", "7z", "tar", "gz", "bz2",
|
||||
"exe", "dll", "so", "dylib", "bin"
|
||||
}
|
||||
|
||||
local is_problematic_file = false
|
||||
local file_extension = ""
|
||||
|
||||
for _, ext in ipairs(problematic_extensions) do
|
||||
if current_filename:match("%." .. ext .. "$") then
|
||||
is_problematic_file = true
|
||||
file_extension = ext
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
-- Performance recommendations
|
||||
local recommendations = {}
|
||||
|
||||
if type(memory_mb) == "number" and memory_mb > 500 then
|
||||
table.insert(recommendations, "High memory usage: " .. memory_mb .. "MB - Consider disabling heavy plugins")
|
||||
end
|
||||
|
||||
if buffer_count > 20 then
|
||||
table.insert(recommendations, "Many buffers open: " .. buffer_count .. " - Close unused buffers")
|
||||
end
|
||||
|
||||
if lsp_count > 5 then
|
||||
table.insert(recommendations, "Many LSP servers: " .. lsp_count .. " - Consider disabling unused language servers")
|
||||
end
|
||||
|
||||
if startup_time > 1000 then
|
||||
table.insert(recommendations, "Slow startup: " .. startup_time .. "ms - Check plugin loading order")
|
||||
end
|
||||
|
||||
if error_count > 10 then
|
||||
table.insert(recommendations, "Many LSP errors: " .. error_count .. " - Check file syntax and LSP configuration")
|
||||
end
|
||||
|
||||
if is_problematic_file then
|
||||
table.insert(recommendations, "Current file type (" .. file_extension .. ") may cause LSP issues - Use safe file search")
|
||||
end
|
||||
|
||||
if current_line_count > 10000 then
|
||||
table.insert(recommendations, "Large file (" .. current_line_count .. " lines) - Consider disabling heavy features")
|
||||
end
|
||||
|
||||
-- Display results
|
||||
local output = string.format([[
|
||||
Performance Report:
|
||||
==================
|
||||
Startup Time: %dms
|
||||
Memory Usage: %s
|
||||
Active Buffers: %d
|
||||
Active Windows: %d
|
||||
Active Tabs: %d
|
||||
LSP Servers: %d
|
||||
Treesitter: %s
|
||||
LSP Errors: %d
|
||||
LSP Warnings: %d
|
||||
|
||||
Current File Analysis:
|
||||
=====================
|
||||
Filename: %s
|
||||
Filetype: %s
|
||||
Line Count: %d
|
||||
Potential Issues: %s
|
||||
|
||||
Performance Recommendations:
|
||||
]], startup_time, tostring(memory_mb), buffer_count, window_count, tab_count, lsp_count, ts_active, error_count, warning_count,
|
||||
current_filename, current_filetype, current_line_count, is_problematic_file and "Yes (" .. file_extension .. ")" or "No")
|
||||
|
||||
if #recommendations > 0 then
|
||||
for _, rec in ipairs(recommendations) do
|
||||
output = output .. "- " .. rec .. "\n"
|
||||
end
|
||||
else
|
||||
output = output .. "- No immediate performance issues detected\n"
|
||||
end
|
||||
|
||||
-- Add LSP-specific recommendations
|
||||
if lsp_count > 0 then
|
||||
output = output .. "\nLSP Status:\n"
|
||||
for _, client in ipairs(active_clients) do
|
||||
local status = "Unknown"
|
||||
if client.is_stopped then
|
||||
status = "Stopped"
|
||||
elseif client.workspace_folders then
|
||||
status = "Active"
|
||||
end
|
||||
output = output .. "- " .. client.name .. ": " .. status .. "\n"
|
||||
end
|
||||
end
|
||||
|
||||
-- Create a new buffer to display the report
|
||||
local buf = vim.api.nvim_create_buf(false, true)
|
||||
local win = vim.api.nvim_open_win(buf, true, {
|
||||
relative = "editor",
|
||||
width = 80,
|
||||
height = 25,
|
||||
row = 2,
|
||||
col = 2,
|
||||
style = "minimal",
|
||||
border = "rounded",
|
||||
})
|
||||
|
||||
vim.api.nvim_buf_set_lines(buf, 0, -1, false, vim.split(output, "\n"))
|
||||
vim.api.nvim_buf_set_option(buf, "modifiable", false)
|
||||
vim.api.nvim_buf_set_option(buf, "filetype", "markdown")
|
||||
|
||||
-- Add keymaps to close the window
|
||||
local opts = { buffer = buf, noremap = true, silent = true }
|
||||
vim.keymap.set("n", "q", "<cmd>close<CR>", opts)
|
||||
vim.keymap.set("n", "<ESC>", "<cmd>close<CR>", opts)
|
||||
|
||||
-- Auto-close after 15 seconds
|
||||
vim.defer_fn(function()
|
||||
if vim.api.nvim_win_is_valid(win) then
|
||||
vim.api.nvim_win_close(win, true)
|
||||
end
|
||||
end, 15000)
|
||||
|
||||
local end_time = vim.loop.hrtime()
|
||||
local function_time = (end_time - start_time) / 1000000
|
||||
print("Performance check completed in " .. string.format("%.2f", function_time) .. "ms")
|
||||
end
|
||||
|
||||
-- Function to profile a specific operation
|
||||
function M.profile_operation(operation_name, operation_func)
|
||||
local start_time = vim.loop.hrtime()
|
||||
|
||||
-- Run the operation
|
||||
local success, result = pcall(operation_func)
|
||||
|
||||
local end_time = vim.loop.hrtime()
|
||||
local duration = (end_time - start_time) / 1000000
|
||||
|
||||
if success then
|
||||
print(string.format("Operation '%s' completed in %.2fms", operation_name, duration))
|
||||
return result
|
||||
else
|
||||
print(string.format("Operation '%s' failed after %.2fms: %s", operation_name, duration, result))
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
-- Function to check if specific plugins are causing issues
|
||||
function M.check_plugin_performance()
|
||||
local plugins_to_check = {
|
||||
"nvim-treesitter",
|
||||
"nvim-lspconfig",
|
||||
"nvim-cmp",
|
||||
"telescope.nvim",
|
||||
"which-key.nvim",
|
||||
}
|
||||
|
||||
local results = {}
|
||||
|
||||
for _, plugin_name in ipairs(plugins_to_check) do
|
||||
local start_time = vim.loop.hrtime()
|
||||
local success, plugin = pcall(require, plugin_name)
|
||||
local end_time = vim.loop.hrtime()
|
||||
local load_time = (end_time - start_time) / 1000000
|
||||
|
||||
table.insert(results, {
|
||||
name = plugin_name,
|
||||
loaded = success,
|
||||
load_time = load_time,
|
||||
status = success and "OK" or "Failed"
|
||||
})
|
||||
end
|
||||
|
||||
-- Display results
|
||||
local output = "Plugin Performance Check:\n=======================\n"
|
||||
for _, result in ipairs(results) do
|
||||
output = output .. string.format("%s: %s (%.2fms)\n",
|
||||
result.name, result.status, result.load_time)
|
||||
end
|
||||
|
||||
print(output)
|
||||
return results
|
||||
end
|
||||
|
||||
-- Function to optimize current buffer
|
||||
function M.optimize_buffer()
|
||||
local buf = vim.api.nvim_get_current_buf()
|
||||
local filetype = vim.api.nvim_buf_get_option(buf, "filetype")
|
||||
|
||||
-- Disable heavy features for large files
|
||||
local line_count = vim.api.nvim_buf_line_count(buf)
|
||||
|
||||
if line_count > 10000 then
|
||||
-- Disable treesitter for very large files
|
||||
vim.api.nvim_buf_set_option(buf, "syntax", "off")
|
||||
print("Large file detected (" .. line_count .. " lines). Disabled syntax highlighting for performance.")
|
||||
end
|
||||
|
||||
-- Optimize buffer-specific settings
|
||||
vim.api.nvim_buf_set_option(buf, "foldmethod", "manual")
|
||||
vim.api.nvim_buf_set_option(buf, "foldlevel", 99)
|
||||
|
||||
print("Buffer optimized for performance")
|
||||
end
|
||||
|
||||
-- Function to check LSP health and fix common issues
|
||||
function M.check_lsp_health()
|
||||
local active_clients = vim.lsp.get_active_clients()
|
||||
local output = "LSP Health Check:\n================\n"
|
||||
|
||||
if #active_clients == 0 then
|
||||
output = output .. "No LSP clients active\n"
|
||||
else
|
||||
for _, client in ipairs(active_clients) do
|
||||
local status = "Unknown"
|
||||
if client.is_stopped then
|
||||
status = "Stopped"
|
||||
elseif client.workspace_folders then
|
||||
status = "Active"
|
||||
end
|
||||
|
||||
output = output .. string.format("- %s: %s\n", client.name, status)
|
||||
|
||||
-- Check for common LSP issues
|
||||
if client.config and client.config.flags then
|
||||
if not client.config.flags.debounce_text_changes then
|
||||
output = output .. " ⚠️ No text change debouncing\n"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Check current buffer LSP status
|
||||
local current_buf = vim.api.nvim_get_current_buf()
|
||||
local attached_clients = vim.lsp.get_clients({ bufnr = current_buf })
|
||||
|
||||
if #attached_clients > 0 then
|
||||
output = output .. "\nCurrent Buffer LSP:\n"
|
||||
for _, client in ipairs(attached_clients) do
|
||||
output = output .. string.format("- %s attached\n", client.name)
|
||||
end
|
||||
else
|
||||
output = output .. "\nNo LSP attached to current buffer\n"
|
||||
end
|
||||
|
||||
print(output)
|
||||
return active_clients
|
||||
end
|
||||
|
||||
-- Function to safely restart LSP for current buffer
|
||||
function M.restart_lsp()
|
||||
local current_buf = vim.api.nvim_get_current_buf()
|
||||
local attached_clients = vim.lsp.get_clients({ bufnr = current_buf })
|
||||
|
||||
if #attached_clients > 0 then
|
||||
for _, client in ipairs(attached_clients) do
|
||||
client.stop()
|
||||
print("Stopped LSP client: " .. client.name)
|
||||
end
|
||||
|
||||
-- Restart LSP after a short delay
|
||||
vim.defer_fn(function()
|
||||
vim.cmd("LspStart")
|
||||
print("LSP restarted for current buffer")
|
||||
end, 100)
|
||||
else
|
||||
print("No LSP clients attached to current buffer")
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -1,24 +1,47 @@
|
||||
-- Load compatibility layer first
|
||||
require("cargdev.core.compatibility").setup()
|
||||
|
||||
-- Load startup optimizations early
|
||||
require("cargdev.core.startup_optimization")
|
||||
|
||||
require("cargdev.core.options")
|
||||
require("cargdev.core.keymaps")
|
||||
|
||||
-- Load all Lua files inside `cargdev/core/function/`
|
||||
-- Load all Lua files inside `cargdev/core/function/` AFTER plugins are loaded
|
||||
local function load_functions()
|
||||
local function_path = vim.fn.stdpath("config") .. "/lua/cargdev/core/function"
|
||||
local scan = vim.fn.globpath(function_path, "*.lua", false, true)
|
||||
|
||||
for _, file in ipairs(scan) do
|
||||
local module_name = "cargdev.core.function." .. file:match("([^/]+)%.lua$")
|
||||
local success, err = pcall(require, module_name)
|
||||
-- Skip notification manager as it's loaded separately
|
||||
if module_name ~= "cargdev.core.function.notification_manager" then
|
||||
local success, err = pcall(require, module_name)
|
||||
|
||||
if not success then
|
||||
vim.notify("Error loading function module: " .. module_name .. "\n" .. err, vim.log.levels.ERROR)
|
||||
if not success then
|
||||
vim.notify("Error loading function module: " .. module_name .. "\n" .. err, vim.log.levels.ERROR)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Defer function loading until after plugins are loaded
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "LazyDone",
|
||||
callback = function()
|
||||
-- Load notification manager after plugins with error handling
|
||||
local success, err = pcall(require, "cargdev.core.function.notification_manager")
|
||||
if not success then
|
||||
-- Use safe echo instead of vim.notify to avoid circular dependency
|
||||
local safe_msg = tostring(err):gsub("'", "\\'")
|
||||
vim.api.nvim_echo({{"Warning: Notification manager failed to load: " .. safe_msg, "WarningMsg"}}, false, {})
|
||||
end
|
||||
|
||||
-- Load all other functions
|
||||
load_functions()
|
||||
end,
|
||||
once = true,
|
||||
})
|
||||
|
||||
--[[ vim.api.nvim_create_autocmd("BufReadPost", {
|
||||
once = true,
|
||||
@@ -27,4 +50,3 @@ end
|
||||
end
|
||||
})
|
||||
]]
|
||||
load_functions()
|
||||
|
||||
@@ -15,5 +15,29 @@ keymap.set("i", "jk", "<ESC>", opts) -- Exit insert mode with jk
|
||||
keymap.set("n", "<leader>nh", ":nohl<CR>", opts) -- Clear search highlights
|
||||
keymap.set("n", "x", '"_x', opts) -- Delete character without copying into register
|
||||
|
||||
-- Comment keymaps
|
||||
keymap.set("n", "gcc", "<cmd>CommentToggle<CR>", { desc = "Toggle comment line" })
|
||||
keymap.set("n", "gc", "<cmd>CommentToggle<CR>", { desc = "Toggle comment line" })
|
||||
keymap.set("v", "gc", "<cmd>CommentToggle<CR>", { desc = "Toggle comment selection" })
|
||||
keymap.set("n", "gbc", "<cmd>CommentToggle<CR>", { desc = "Toggle comment block" })
|
||||
keymap.set("v", "gb", "<cmd>CommentToggle<CR>", { desc = "Toggle comment block" })
|
||||
|
||||
-- Save and quit (additional)
|
||||
keymap.set("n", "<leader>Q", ":qa!<CR>", { desc = "Quit all" })
|
||||
keymap.set("n", "<leader>Q", ":qa!<CR>", { desc = "Quit all" })
|
||||
|
||||
-- Performance monitoring keymaps
|
||||
keymap.set("n", "<leader>pp", "<cmd>lua require('cargdev.core.function.performance_monitor').check_performance()<CR>", { desc = "Check performance" })
|
||||
keymap.set("n", "<leader>po", "<cmd>lua require('cargdev.core.function.performance_monitor').check_plugin_performance()<CR>", { desc = "Check plugin performance" })
|
||||
keymap.set("n", "<leader>pb", "<cmd>lua require('cargdev.core.function.performance_monitor').optimize_buffer()<CR>", { desc = "Optimize current buffer" })
|
||||
|
||||
-- LSP health and troubleshooting keymaps
|
||||
keymap.set("n", "<leader>pl", "<cmd>lua require('cargdev.core.function.performance_monitor').check_lsp_health()<CR>", { desc = "Check LSP health" })
|
||||
keymap.set("n", "<leader>pr", "<cmd>lua require('cargdev.core.function.performance_monitor').restart_lsp()<CR>", { desc = "Restart LSP" })
|
||||
|
||||
-- Notification management keymaps
|
||||
keymap.set("n", "<leader>nc", "<cmd>lua require('cargdev.core.function.notification_manager').clear_all_notifications()<CR>", { desc = "Clear all notifications" })
|
||||
keymap.set("n", "<leader>nn", "<cmd>lua require('cargdev.core.function.notification_manager').show_notification('Test notification', vim.log.levels.INFO)<CR>", { desc = "Test notification" })
|
||||
|
||||
-- Startup prompt management keymaps
|
||||
keymap.set("n", "<leader>ns", "<cmd>redraw!<CR><cmd>echo ''<CR>", { desc = "Clear startup prompts" })
|
||||
keymap.set("n", "<leader>nr", "<cmd>redraw!<CR>", { desc = "Redraw screen" })
|
||||
@@ -116,6 +116,19 @@ keymap.set("n", "gcA", "<cmd>lua require('Comment.api').insert_eol()<cr>", { des
|
||||
keymap.set("n", "gb", "<cmd>lua require('Comment.api').toggle_current_blockwise()<cr>", { desc = "Toggle block comment" })
|
||||
keymap.set("n", "gbc", "<cmd>lua require('Comment.api').toggle_current_blockwise()<cr>", { desc = "Toggle current block comment" })
|
||||
|
||||
-- =============================================================================
|
||||
-- TELESCOPE KEYMAPS (Enhanced with safe file searching)
|
||||
-- =============================================================================
|
||||
|
||||
-- Safe file search (prevents LSP errors and image freezing)
|
||||
keymap.set("n", "<leader>ff", "<cmd>Telescope safe_files find_files<CR>", { desc = "Find files (safe)" })
|
||||
keymap.set("n", "<leader>fs", "<cmd>Telescope live_grep<CR>", { desc = "Live grep (safe)" })
|
||||
keymap.set("n", "<leader>fg", "<cmd>Telescope git_files<CR>", { desc = "Git files (safe)" })
|
||||
keymap.set("n", "<leader>ft", "<cmd>Telescope text_files find_files<CR>", { desc = "Text files only" })
|
||||
|
||||
-- Regular telescope (use with caution)
|
||||
keymap.set("n", "<leader>fF", "<cmd>Telescope find_files<CR>", { desc = "Find files (all)" })
|
||||
|
||||
-- =============================================================================
|
||||
-- DATABASE KEYMAPS (Temporarily disabled to prevent conflicts)
|
||||
-- =============================================================================
|
||||
|
||||
@@ -31,15 +31,22 @@ opt.softtabstop = 2 -- Number of spaces for soft tabs
|
||||
opt.autoindent = true -- Auto indent
|
||||
opt.smartindent = true -- Smart indent
|
||||
|
||||
-- Performance
|
||||
opt.lazyredraw = false -- Don't redraw while executing macros
|
||||
opt.updatetime = 250 -- Faster completion
|
||||
opt.timeoutlen = 300 -- Faster key sequence completion
|
||||
-- Performance optimizations
|
||||
opt.lazyredraw = true -- Don't redraw while executing macros
|
||||
opt.updatetime = 100 -- Faster completion (reduced from 250)
|
||||
opt.timeoutlen = 200 -- Faster key sequence completion (reduced from 300)
|
||||
opt.redrawtime = 1500 -- Allow more time for loading syntax
|
||||
opt.synmaxcol = 240 -- Only highlight the first 240 columns
|
||||
opt.maxmempattern = 1000 -- Reduce memory for pattern matching
|
||||
opt.hidden = true -- Allow switching buffers without saving
|
||||
opt.scrolljump = 1 -- Minimal number of screen lines to scroll
|
||||
opt.scrolloff = 3 -- Keep 3 lines above/below cursor (reduced from 8)
|
||||
opt.sidescrolloff = 3 -- Keep 3 columns left/right of cursor (reduced from 8)
|
||||
|
||||
-- UI settings
|
||||
opt.number = true -- Show line numbers
|
||||
opt.relativenumber = true -- Show relative line numbers
|
||||
opt.cursorline = true -- Highlight current line
|
||||
opt.cursorline = false -- Disable cursor line highlighting for performance
|
||||
opt.cursorcolumn = false -- Don't highlight current column
|
||||
opt.signcolumn = "yes" -- Always show sign column
|
||||
|
||||
@@ -70,8 +77,6 @@ opt.formatoptions:append("n") -- Recognize numbered lists
|
||||
opt.formatoptions:append("j") -- Remove comment leader when joining lines
|
||||
|
||||
-- Scroll settings for wrapped text
|
||||
opt.scrolloff = 8 -- Keep 8 lines above/below cursor
|
||||
opt.sidescrolloff = 8 -- Keep 8 columns left/right of cursor
|
||||
opt.showmatch = true -- Show matching brackets
|
||||
opt.matchtime = 2 -- How long to show matching brackets
|
||||
|
||||
@@ -110,9 +115,6 @@ g.loaded_ruby_provider = 0 -- Disable Ruby provider (optional)
|
||||
-- Lua specific settings
|
||||
opt.runtimepath:append(vim.fn.stdpath("config") .. "/lua")
|
||||
|
||||
-- Improve performance for large files
|
||||
opt.maxmempattern = 2000 -- Increase memory for pattern matching
|
||||
|
||||
-- Better diff
|
||||
opt.diffopt:append("algorithm:patience")
|
||||
opt.diffopt:append("indent-heuristic")
|
||||
|
||||
215
lua/cargdev/core/startup_optimization.lua
Normal file
215
lua/cargdev/core/startup_optimization.lua
Normal file
@@ -0,0 +1,215 @@
|
||||
-- Startup performance optimizations
|
||||
local M = {}
|
||||
|
||||
-- Function to optimize startup performance
|
||||
function M.optimize_startup()
|
||||
-- Record startup time
|
||||
local start_time = vim.loop.hrtime()
|
||||
|
||||
-- Disable unused providers
|
||||
vim.g.loaded_python3_provider = 0
|
||||
vim.g.loaded_ruby_provider = 0
|
||||
vim.g.loaded_perl_provider = 0
|
||||
|
||||
-- Disable unused builtin plugins
|
||||
local disabled_builtins = {
|
||||
"gzip",
|
||||
"zip",
|
||||
"zipPlugin",
|
||||
"tar",
|
||||
"tarPlugin",
|
||||
"getscript",
|
||||
"getscriptPlugin",
|
||||
"vimball",
|
||||
"vimballPlugin",
|
||||
"2html_plugin",
|
||||
"logipat",
|
||||
"rrhelper",
|
||||
"spellfile_plugin",
|
||||
"matchit",
|
||||
"netrw",
|
||||
"netrwPlugin",
|
||||
"netrwSettings",
|
||||
"netrwFileHandlers",
|
||||
}
|
||||
|
||||
for _, plugin in pairs(disabled_builtins) do
|
||||
vim.g["loaded_" .. plugin] = 1
|
||||
end
|
||||
|
||||
-- Optimize filetype detection
|
||||
vim.g.do_filetype_lua = 1
|
||||
vim.g.did_load_filetypes = 0
|
||||
|
||||
-- Fix lazyredraw conflict with Noice - but only after LazyVim loads
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "LazyDone",
|
||||
callback = function()
|
||||
vim.opt.lazyredraw = false -- Disable to prevent Noice conflicts
|
||||
end,
|
||||
once = true,
|
||||
})
|
||||
|
||||
-- Optimize completion settings
|
||||
vim.opt.completeopt = "menuone,noselect"
|
||||
vim.opt.pumheight = 10 -- Limit completion menu height
|
||||
|
||||
-- Optimize search settings
|
||||
vim.opt.hlsearch = false
|
||||
vim.opt.incsearch = true
|
||||
|
||||
-- Optimize syntax highlighting
|
||||
vim.opt.synmaxcol = 240
|
||||
vim.opt.redrawtime = 1500
|
||||
|
||||
-- Optimize folding
|
||||
vim.opt.foldmethod = "manual"
|
||||
vim.opt.foldlevel = 99
|
||||
|
||||
-- Completely eliminate "Press ENTER" prompts
|
||||
vim.opt.shortmess = vim.opt.shortmess + "I" -- No intro message
|
||||
vim.opt.shortmess = vim.opt.shortmess + "c" -- No completion messages
|
||||
vim.opt.shortmess = vim.opt.shortmess + "F" -- No file info message
|
||||
vim.opt.shortmess = vim.opt.shortmess + "W" -- No "written" message
|
||||
vim.opt.shortmess = vim.opt.shortmess + "A" -- No attention message
|
||||
vim.opt.shortmess = vim.opt.shortmess + "o" -- No overwrite messages
|
||||
vim.opt.shortmess = vim.opt.shortmess + "t" -- No truncation messages
|
||||
vim.opt.shortmess = vim.opt.shortmess + "T" -- No truncation messages
|
||||
vim.opt.shortmess = vim.opt.shortmess + "f" -- No file info messages
|
||||
vim.opt.shortmess = vim.opt.shortmess + "i" -- No intro messages
|
||||
vim.opt.shortmess = vim.opt.shortmess + "l" -- No line number messages
|
||||
vim.opt.shortmess = vim.opt.shortmess + "m" -- No modification messages
|
||||
vim.opt.shortmess = vim.opt.shortmess + "n" -- No line number messages
|
||||
vim.opt.shortmess = vim.opt.shortmess + "r" -- No read messages
|
||||
vim.opt.shortmess = vim.opt.shortmess + "s" -- No search messages
|
||||
vim.opt.shortmess = vim.opt.shortmess + "x" -- No truncation messages
|
||||
|
||||
-- Disable swap file messages completely
|
||||
vim.opt.shortmess = vim.opt.shortmess + "O" -- No overwrite messages
|
||||
|
||||
-- Disable all startup messages
|
||||
vim.opt.cmdheight = 0 -- Reduce command line height
|
||||
vim.opt.showmode = false -- Don't show mode in command line
|
||||
|
||||
-- Record end time and calculate duration
|
||||
local end_time = vim.loop.hrtime()
|
||||
local duration = (end_time - start_time) / 1000000
|
||||
|
||||
-- Store startup time for performance monitoring
|
||||
vim.g.startup_time = duration
|
||||
|
||||
print("Startup optimizations applied in " .. string.format("%.2f", duration) .. "ms")
|
||||
end
|
||||
|
||||
-- Function to defer heavy operations
|
||||
function M.defer_heavy_operations()
|
||||
-- Defer treesitter loading
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "LazyDone",
|
||||
callback = function()
|
||||
vim.defer_fn(function()
|
||||
if vim.fn.exists(":TSBufEnable") > 0 then
|
||||
vim.cmd("TSBufEnable highlight")
|
||||
end
|
||||
end, 100)
|
||||
end,
|
||||
once = true,
|
||||
})
|
||||
|
||||
-- Defer LSP setup for non-critical buffers
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "LazyDone",
|
||||
callback = function()
|
||||
vim.defer_fn(function()
|
||||
-- Enable LSP for current buffer if it's a supported filetype
|
||||
local supported_ft = {
|
||||
"lua", "javascript", "typescript", "python", "java", "cpp", "c", "rust", "go",
|
||||
"html", "css", "json", "yaml", "markdown"
|
||||
}
|
||||
|
||||
local current_ft = vim.bo.filetype
|
||||
if vim.tbl_contains(supported_ft, current_ft) then
|
||||
vim.cmd("LspStart")
|
||||
end
|
||||
end, 200)
|
||||
end,
|
||||
once = true,
|
||||
})
|
||||
|
||||
-- Defer completion setup
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "LazyDone",
|
||||
callback = function()
|
||||
vim.defer_fn(function()
|
||||
if vim.fn.exists(":CmpStatus") > 0 then
|
||||
vim.cmd("CmpStatus")
|
||||
end
|
||||
end, 300)
|
||||
end,
|
||||
once = true,
|
||||
})
|
||||
end
|
||||
|
||||
-- Function to check if we're in a large repository
|
||||
function M.check_repo_size()
|
||||
local cwd = vim.fn.getcwd()
|
||||
local git_dir = cwd .. "/.git"
|
||||
|
||||
if vim.fn.isdirectory(git_dir) > 0 then
|
||||
-- Check if this is a large repository
|
||||
local file_count = tonumber(vim.fn.system("git ls-files | wc -l")) or 0
|
||||
|
||||
if file_count > 10000 then
|
||||
-- Large repository detected, apply additional optimizations
|
||||
vim.opt.tags = "" -- Disable tag loading
|
||||
vim.opt.cursorline = false -- Disable cursor line
|
||||
vim.opt.relativenumber = false -- Disable relative numbers
|
||||
|
||||
print("Large repository detected (" .. file_count .. " lines). Applied additional optimizations.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Function to completely eliminate startup prompts
|
||||
function M.eliminate_startup_prompts()
|
||||
-- Create autocmd to handle any remaining startup messages
|
||||
vim.api.nvim_create_autocmd("VimEnter", {
|
||||
callback = function()
|
||||
-- Clear any startup messages immediately
|
||||
vim.cmd("redraw!")
|
||||
vim.cmd("echo ''")
|
||||
|
||||
-- Force clear any pending messages
|
||||
vim.defer_fn(function()
|
||||
vim.cmd("redraw!")
|
||||
vim.cmd("echo ''")
|
||||
end, 50)
|
||||
end,
|
||||
once = true,
|
||||
})
|
||||
|
||||
-- Create autocmd to handle any message events - use valid events
|
||||
vim.api.nvim_create_autocmd("BufReadPost", {
|
||||
callback = function()
|
||||
-- Clear messages that might cause prompts
|
||||
vim.cmd("redraw!")
|
||||
end,
|
||||
})
|
||||
|
||||
-- Override the message display to prevent prompts
|
||||
local original_echo = vim.cmd.echo
|
||||
vim.cmd.echo = function(msg)
|
||||
-- Only echo if it's not a startup message
|
||||
if not tostring(msg):match("Press ENTER") and not tostring(msg):match("lazyredraw") then
|
||||
original_echo(msg)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Initialize startup optimizations
|
||||
M.optimize_startup()
|
||||
M.defer_heavy_operations()
|
||||
M.check_repo_size()
|
||||
M.eliminate_startup_prompts()
|
||||
|
||||
return M
|
||||
@@ -1,56 +0,0 @@
|
||||
-- return {
|
||||
-- {
|
||||
-- "yetone/avante.nvim",
|
||||
-- event = "VeryLazy",
|
||||
-- lazy = false,
|
||||
-- version = false, -- Always pull the latest change
|
||||
-- opts = {
|
||||
-- provider = "cargdev", -- API provider configuration
|
||||
-- providers = {
|
||||
-- cargdev = {
|
||||
-- name = "cargdev", -- Optional
|
||||
-- endpoint = "https://api-ai.cargdev.io", -- API endpoint
|
||||
-- api_key_name = "CARGDEV_API_KEY", -- reference the ENV VAR below
|
||||
-- model = "deepseek-r1:latest",
|
||||
-- __inherited_from = "ollama", -- ensures compatibility
|
||||
-- max_tokens = 8192,
|
||||
-- },
|
||||
-- },
|
||||
-- },
|
||||
-- -- Optional: Build from source if required
|
||||
-- build = "make",
|
||||
-- dependencies = {
|
||||
-- "nvim-treesitter/nvim-treesitter", -- Syntax highlighting support
|
||||
-- "stevearc/dressing.nvim", -- UI elements
|
||||
-- "nvim-lua/plenary.nvim", -- Utility library
|
||||
-- "MunifTanjim/nui.nvim", -- UI library for modal components
|
||||
-- -- Optional dependencies:
|
||||
-- "nvim-tree/nvim-web-devicons", -- Icons support
|
||||
-- "zbirenbaum/copilot.lua", -- Copilot integration
|
||||
-- {
|
||||
-- "HakonHarnes/img-clip.nvim", -- Image pasting support
|
||||
-- event = "VeryLazy",
|
||||
-- opts = {
|
||||
-- -- Recommended settings
|
||||
-- default = {
|
||||
-- embed_image_as_base64 = false,
|
||||
-- prompt_for_file_name = false,
|
||||
-- drag_and_drop = {
|
||||
-- insert_mode = true,
|
||||
-- },
|
||||
-- use_absolute_path = true, -- For Windows users
|
||||
-- },
|
||||
-- },
|
||||
-- },
|
||||
-- {
|
||||
-- "MeanderingProgrammer/render-markdown.nvim",
|
||||
-- ft = { "markdown", "Avante" },
|
||||
-- config = function()
|
||||
-- require("render-markdown").setup({
|
||||
-- file_types = { "markdown", "Avante" },
|
||||
-- })
|
||||
-- end,
|
||||
-- },
|
||||
-- },
|
||||
-- },
|
||||
-- }
|
||||
@@ -18,7 +18,7 @@ return {
|
||||
" ",
|
||||
" ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ ",
|
||||
" ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ ",
|
||||
" ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ ",
|
||||
" ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██╗ ",
|
||||
" ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ ",
|
||||
" ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ ",
|
||||
" ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ",
|
||||
@@ -27,14 +27,20 @@ return {
|
||||
" 🚀 Welcome to CarGDev Neovim - Customize Your Flow! 🚀 ",
|
||||
}
|
||||
|
||||
-- 📂 Set menu with improved icons
|
||||
-- 📂 Set menu with improved icons and performance tools
|
||||
dashboard.section.buttons.val = {
|
||||
dashboard.button("f", "🔎 Find File", "<cmd>lua require('snacks.picker').files()<CR>"),
|
||||
dashboard.button("n", "📜 New File", "<cmd>ene<CR>"),
|
||||
dashboard.button("g", "📝 Find Text", "<cmd>lua require('snacks.picker').grep()<CR>"),
|
||||
dashboard.button("r", "📚 Recent Files", "<cmd>lua require('snacks.picker').oldfiles()<CR>"),
|
||||
dashboard.button("f", "🔎 Find File (Safe)", "<cmd>Telescope find_files<CR>"),
|
||||
dashboard.button("n", "📄 New File", "<cmd>ene<CR>"),
|
||||
dashboard.button("g", "📝 Find Text", "<cmd>Telescope live_grep<CR>"),
|
||||
dashboard.button("r", "📚 Recent Files", "<cmd>Telescope oldfiles<CR>"),
|
||||
dashboard.button("t", "🌳 File Tree", "<cmd>NvimTreeToggle<CR>"),
|
||||
dashboard.button("c", "⚙️ Config", "<cmd>e ~/.config/nvim/init.lua<CR>"),
|
||||
dashboard.button("L", "🦥 Lazy", "<cmd>Lazy<CR>"),
|
||||
dashboard.button("p", "📊 Performance", "<cmd>lua require('cargdev.core.function.performance_monitor').check_performance()<CR>"),
|
||||
dashboard.button("l", "🔧 LSP Health", "<cmd>lua require('cargdev.core.function.performance_monitor').check_lsp_health()<CR>"),
|
||||
dashboard.button("s", "🧩 Sudoku", "<cmd>Sudoku<CR>"),
|
||||
dashboard.button("e", "💻 LeetCode", "<cmd>Leet<CR>"),
|
||||
dashboard.button("m", "🔨 Mason", "<cmd>Mason<CR>"),
|
||||
dashboard.button("q", "🚪 Quit", "<cmd>qa<CR>"),
|
||||
}
|
||||
|
||||
@@ -101,5 +107,42 @@ return {
|
||||
|
||||
-- 🔥 Disable folding on alpha buffer
|
||||
vim.cmd([[autocmd FileType alpha setlocal nofoldenable]])
|
||||
|
||||
-- 🚫 Suppress startup messages that can overlap with dashboard
|
||||
vim.api.nvim_create_autocmd("VimEnter", {
|
||||
callback = function()
|
||||
-- Clear any startup messages
|
||||
vim.cmd("redraw!")
|
||||
|
||||
-- Suppress specific startup messages
|
||||
vim.opt.shortmess = vim.opt.shortmess + "I" -- No intro message
|
||||
vim.opt.shortmess = vim.opt.shortmess + "c" -- No completion messages
|
||||
vim.opt.shortmess = vim.opt.shortmess + "F" -- No file info message
|
||||
vim.opt.shortmess = vim.opt.shortmess + "W" -- No "written" message
|
||||
vim.opt.shortmess = vim.opt.shortmess + "A" -- No attention message
|
||||
vim.opt.shortmess = vim.opt.shortmess + "o" -- No overwrite messages
|
||||
|
||||
-- Clear any existing messages
|
||||
vim.cmd("echo ''")
|
||||
end,
|
||||
once = true,
|
||||
})
|
||||
|
||||
-- 🎨 Improve dashboard appearance and reduce overlapping
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "alpha",
|
||||
callback = function()
|
||||
-- Set buffer options for better appearance
|
||||
vim.opt_local.number = false
|
||||
vim.opt_local.relativenumber = false
|
||||
vim.opt_local.cursorline = false
|
||||
vim.opt_local.cursorcolumn = false
|
||||
vim.opt_local.signcolumn = "no"
|
||||
vim.opt_local.foldcolumn = "0"
|
||||
|
||||
-- Clear any messages that might overlap
|
||||
vim.cmd("redraw!")
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
||||
@@ -8,12 +8,32 @@ return {
|
||||
-- import comment plugin safely
|
||||
local comment = require("Comment")
|
||||
|
||||
local ts_context_commentstring = require("ts_context_commentstring.integrations.comment_nvim")
|
||||
|
||||
-- enable comment
|
||||
-- Check if treesitter context commentstring is available
|
||||
local ok, ts_context_commentstring = pcall(require, "ts_context_commentstring.integrations.comment_nvim")
|
||||
|
||||
-- enable comment with safe configuration
|
||||
comment.setup({
|
||||
-- for commenting tsx, jsx, svelte, html files
|
||||
pre_hook = ts_context_commentstring.create_pre_hook(),
|
||||
pre_hook = ok and ts_context_commentstring.create_pre_hook() or nil,
|
||||
-- Add explicit commentstring fallbacks
|
||||
opleader = {
|
||||
line = "gc",
|
||||
block = "gb",
|
||||
},
|
||||
toggler = {
|
||||
line = "gcc",
|
||||
block = "gbc",
|
||||
},
|
||||
extra = {
|
||||
above = "gcO",
|
||||
below = "gco",
|
||||
eol = "gcA",
|
||||
},
|
||||
mappings = {
|
||||
basic = true,
|
||||
extra = true,
|
||||
extended = false,
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
-- return {
|
||||
-- {
|
||||
-- "olimorris/codecompanion.nvim",
|
||||
-- event = "VeryLazy",
|
||||
-- lazy = false,
|
||||
-- version = false,
|
||||
-- opts = {
|
||||
-- adapters = {
|
||||
-- openai = function()
|
||||
-- return require("codecompanion.adapters").extend("openai", {
|
||||
-- name = "openai",
|
||||
-- model = "codellama:7b",
|
||||
-- endpoint = "https://api-ai.cargdev.io/v1",
|
||||
-- api_key = os.getenv("CARGDEV_API_KEY"),
|
||||
-- max_tokens = 2048,
|
||||
-- })
|
||||
-- end,
|
||||
-- },
|
||||
-- strategies = {
|
||||
-- chat = { adapter = "openai" },
|
||||
-- inline = { adapter = "openai" },
|
||||
-- agent = { adapter = "openai" },
|
||||
-- },
|
||||
-- },
|
||||
-- dependencies = {
|
||||
-- "nvim-lua/plenary.nvim",
|
||||
-- "nvim-treesitter/nvim-treesitter",
|
||||
-- "nvim-telescope/telescope.nvim",
|
||||
-- },
|
||||
-- }
|
||||
-- }
|
||||
--
|
||||
@@ -1,5 +1,7 @@
|
||||
return {
|
||||
"mfussenegger/nvim-dap",
|
||||
event = "VeryLazy", -- Changed from immediate loading to lazy loading
|
||||
cmd = { "Dap", "DapUI", "DapContinue", "DapToggleBreakpoint" }, -- Load on command
|
||||
dependencies = {
|
||||
{ "nvim-neotest/nvim-nio", lazy = false },
|
||||
"rcarriga/nvim-dap-ui",
|
||||
@@ -9,6 +11,7 @@ return {
|
||||
"Weissle/persistent-breakpoints.nvim",
|
||||
{
|
||||
"nvim-neotest/neotest",
|
||||
event = "VeryLazy",
|
||||
dependencies = {
|
||||
"nvim-neotest/neotest-jest",
|
||||
"nvim-neotest/neotest-python",
|
||||
|
||||
333
lua/cargdev/plugins/essential_enhancements.lua
Normal file
333
lua/cargdev/plugins/essential_enhancements.lua
Normal file
@@ -0,0 +1,333 @@
|
||||
return {
|
||||
-- Enhanced notifications with better positioning
|
||||
{
|
||||
"rcarriga/nvim-notify",
|
||||
event = "VeryLazy",
|
||||
config = function()
|
||||
vim.notify = require("notify")
|
||||
|
||||
-- Configure notifications to avoid overlapping
|
||||
require("notify").setup({
|
||||
-- Position notifications to avoid overlapping with dashboard
|
||||
stages = "fade_in_slide_out",
|
||||
timeout = 3000,
|
||||
background_colour = "#000000",
|
||||
max_width = 50,
|
||||
max_height = 10,
|
||||
default_timeout = 4000,
|
||||
top_down = false, -- Show newer notifications at the bottom
|
||||
render = "minimal",
|
||||
minimum_width = 20,
|
||||
icons = {
|
||||
ERROR = " ",
|
||||
WARN = " ",
|
||||
INFO = " ",
|
||||
DEBUG = " ",
|
||||
TRACE = " ",
|
||||
},
|
||||
-- Position notifications away from dashboard
|
||||
on_open = function(win)
|
||||
-- Move notification window to avoid overlapping with alpha dashboard
|
||||
local config = vim.api.nvim_win_get_config(win)
|
||||
if config.relative == "editor" then
|
||||
-- Position notifications in the top-right, but not overlapping dashboard
|
||||
vim.api.nvim_win_set_config(win, {
|
||||
row = 2,
|
||||
col = vim.o.columns - 60, -- Position from right side
|
||||
relative = "editor",
|
||||
width = 55,
|
||||
height = 8,
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
-- Better session management
|
||||
{
|
||||
"folke/persistence.nvim",
|
||||
event = "BufReadPre",
|
||||
opts = {
|
||||
dir = vim.fn.stdpath("state") .. "/sessions",
|
||||
options = { "buffers", "curdir", "tabpages", "winsize", "help" }
|
||||
},
|
||||
keys = {
|
||||
{ "<leader>qs", function() require("persistence").load() end, desc = "Restore Session" },
|
||||
{ "<leader>ql", function() require("persistence").load({ last = true }) end, desc = "Restore Last Session" },
|
||||
{ "<leader>qd", function() require("persistence").stop() end, desc = "Don't Save Current Session" },
|
||||
},
|
||||
},
|
||||
|
||||
-- Project management
|
||||
{
|
||||
"ahmedkhalf/project.nvim",
|
||||
event = "VeryLazy",
|
||||
config = function()
|
||||
require("project_nvim").setup({
|
||||
detection_methods = { "pattern", "lsp" },
|
||||
patterns = {
|
||||
".git",
|
||||
"package.json",
|
||||
"pyproject.toml",
|
||||
"Cargo.toml",
|
||||
"go.mod",
|
||||
"requirements.txt"
|
||||
},
|
||||
show_hidden = false,
|
||||
silent_chdir = true,
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
-- Better search and replace
|
||||
{
|
||||
"nvim-pack/nvim-spectre",
|
||||
event = "VeryLazy",
|
||||
config = function()
|
||||
require("spectre").setup({
|
||||
color_devicons = true,
|
||||
open_cmd = "vnew",
|
||||
live_update = false, -- Disable for better performance
|
||||
line_sep_start = "┌──────────────────────────────────────────────────────────────────────────────┐",
|
||||
line_sep = "├──────────────────────────────────────────────────────────────────────────────┤",
|
||||
line_sep_end = "└──────────────────────────────────────────────────────────────────────────────┘",
|
||||
})
|
||||
end,
|
||||
keys = {
|
||||
{ "<leader>sr", function() require("spectre").open() end, desc = "Search and Replace" },
|
||||
},
|
||||
},
|
||||
|
||||
-- Enhanced terminal
|
||||
{
|
||||
"akinsho/toggleterm.nvim",
|
||||
version = "*",
|
||||
event = "VeryLazy",
|
||||
opts = {
|
||||
size = 20,
|
||||
open_mapping = [[<c-\>]],
|
||||
shade_filetypes = {},
|
||||
direction = "float",
|
||||
float_opts = {
|
||||
border = "curved",
|
||||
highlights = {
|
||||
border = "Normal",
|
||||
background = "Normal",
|
||||
},
|
||||
},
|
||||
},
|
||||
keys = {
|
||||
{ "<leader>tt", "<cmd>ToggleTerm<CR>", desc = "Toggle Terminal" },
|
||||
{ "<leader>tf", "<cmd>ToggleTerm direction=float<CR>", desc = "Float Terminal" },
|
||||
},
|
||||
},
|
||||
|
||||
-- Better file operations
|
||||
{
|
||||
"chrisgrieser/nvim-early-retirement",
|
||||
event = "VeryLazy",
|
||||
opts = {
|
||||
retirementAgeMins = 1440, -- 24 hours
|
||||
notificationOnAutoClose = true,
|
||||
deleteBufferWhenFileDeleted = true,
|
||||
},
|
||||
},
|
||||
|
||||
-- Enhanced quickfix
|
||||
{
|
||||
"kevinhwang91/nvim-bqf",
|
||||
event = "VeryLazy",
|
||||
config = function()
|
||||
require("bqf").setup({
|
||||
auto_enable = true,
|
||||
preview = {
|
||||
win_height = 12,
|
||||
win_vheight = 12,
|
||||
delay_syntax = 80,
|
||||
border_chars = { "┃", "┃", "━", "━", "┏", "┃", "┃", "┛" },
|
||||
},
|
||||
func_map = {
|
||||
vsplit = "",
|
||||
ptogglemode = "z,",
|
||||
stoggleup = "",
|
||||
},
|
||||
filter = {
|
||||
fzf = {
|
||||
action_for = { ["ctrl-s"] = "split" },
|
||||
extra_opts = { "--bind", "ctrl-o:toggle-all", "--prompt", "> " },
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
-- Better completion menu with improved positioning
|
||||
{
|
||||
"folke/noice.nvim",
|
||||
event = "VeryLazy",
|
||||
dependencies = {
|
||||
"MunifTanjim/nui.nvim",
|
||||
"rcarriga/nvim-notify",
|
||||
},
|
||||
opts = {
|
||||
lsp = {
|
||||
override = {
|
||||
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
|
||||
["vim.lsp.util.stylize_markdown"] = true,
|
||||
["cmp.entry.get_documentation"] = true,
|
||||
},
|
||||
},
|
||||
routes = {
|
||||
{
|
||||
filter = {
|
||||
event = "msg_show",
|
||||
any = {
|
||||
{ find = "%d+L, %d+B" },
|
||||
{ find = "; after #%d+" },
|
||||
{ find = "; before #%d+" },
|
||||
{ find = "%d fewer lines" },
|
||||
{ find = "%d more lines" },
|
||||
},
|
||||
},
|
||||
view = "mini",
|
||||
},
|
||||
-- Route startup messages to avoid overlapping with dashboard
|
||||
{
|
||||
filter = {
|
||||
event = "msg_show",
|
||||
any = {
|
||||
{ find = "ideaDrop loaded!" },
|
||||
{ find = "noice.nvim" },
|
||||
{ find = "lazyredraw" },
|
||||
},
|
||||
},
|
||||
view = "notify",
|
||||
opts = { timeout = 2000 },
|
||||
},
|
||||
},
|
||||
presets = {
|
||||
bottom_search = true,
|
||||
command_palette = true,
|
||||
long_message_to_split = true,
|
||||
inc_rename = true,
|
||||
},
|
||||
-- Position command palette and other UI elements to avoid overlapping
|
||||
cmdline = {
|
||||
position = {
|
||||
row = "50%",
|
||||
col = "50%",
|
||||
},
|
||||
},
|
||||
popupmenu = {
|
||||
position = {
|
||||
row = "50%",
|
||||
col = "50%",
|
||||
},
|
||||
},
|
||||
notify = {
|
||||
-- Position notifications to avoid dashboard overlap
|
||||
position = "top_right",
|
||||
max_width = 50,
|
||||
max_height = 10,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- Better status line
|
||||
{
|
||||
"nvim-lualine/lualine.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = {
|
||||
options = {
|
||||
theme = "auto",
|
||||
globalstatus = true,
|
||||
disabled_filetypes = { statusline = { "dashboard", "alpha" } },
|
||||
component_separators = { left = "│", right = "│" },
|
||||
section_separators = { left = "", right = "" },
|
||||
},
|
||||
sections = {
|
||||
lualine_a = { "mode" },
|
||||
lualine_b = { "branch", "diff", "diagnostics" },
|
||||
lualine_c = { "filename" },
|
||||
lualine_x = { "encoding", "fileformat", "filetype" },
|
||||
lualine_y = { "progress" },
|
||||
lualine_z = { "location" },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- Better buffer management
|
||||
{
|
||||
"akinsho/bufferline.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = {
|
||||
options = {
|
||||
mode = "buffers",
|
||||
separator_style = "slant",
|
||||
always_show_bufferline = false,
|
||||
show_buffer_close_icons = true,
|
||||
show_close_icon = false,
|
||||
color_icons = true,
|
||||
diagnostics = "nvim_lsp",
|
||||
diagnostics_indicator = function(_, _, diag)
|
||||
local icons = require("lazyvim.config").icons.diagnostics
|
||||
local ret = (diag.error and icons.Error .. diag.error .. " " or "")
|
||||
.. (diag.warning and icons.Warn .. diag.warning or "")
|
||||
return vim.trim(ret)
|
||||
end,
|
||||
offsets = {
|
||||
{
|
||||
filetype = "neo-tree",
|
||||
text = "Neo-tree",
|
||||
highlight = "Directory",
|
||||
text_align = "left",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- Better git integration
|
||||
{
|
||||
"lewis6991/gitsigns.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = {
|
||||
signs = {
|
||||
add = { text = "│" },
|
||||
change = { text = "│" },
|
||||
delete = { text = "_" },
|
||||
topdelete = { text = "‾" },
|
||||
changedelete = { text = "~" },
|
||||
untracked = { text = "┆" },
|
||||
},
|
||||
signcolumn = true,
|
||||
numhl = false,
|
||||
linehl = false,
|
||||
word_diff = false,
|
||||
watch_gitdir = {
|
||||
interval = 1000,
|
||||
follow_files = true,
|
||||
},
|
||||
attach_to_untracked = true,
|
||||
current_line_blame = false,
|
||||
current_line_blame_opts = {
|
||||
virt_text = true,
|
||||
virt_text_pos = "eol",
|
||||
delay = 1000,
|
||||
ignore_whitespace = false,
|
||||
},
|
||||
sign_priority = 6,
|
||||
update_debounce = 100,
|
||||
status_formatter = nil,
|
||||
max_file_length = 40000,
|
||||
preview_config = {
|
||||
border = "single",
|
||||
style = "minimal",
|
||||
relative = "cursor",
|
||||
row = 0,
|
||||
col = 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -3,6 +3,15 @@ return {
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
main = "ibl",
|
||||
opts = {
|
||||
indent = { char = "┊" },
|
||||
indent = {
|
||||
char = "┊",
|
||||
exclude_filetypes = { "help", "alpha", "dashboard", "neo-tree", "Trouble", "lazy", "mason" }
|
||||
},
|
||||
scope = {
|
||||
enabled = false
|
||||
},
|
||||
exclude = {
|
||||
filetypes = { "help", "alpha", "dashboard", "neo-tree", "Trouble", "lazy", "mason" }
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,504 +0,0 @@
|
||||
-- return {
|
||||
-- dir = "/Users/carlos/Documents/SSD_Documents/projects/intellij.nvim",
|
||||
-- dependencies = {
|
||||
-- "mfussenegger/nvim-jdtls", -- Java Language Server Protocol
|
||||
-- "mfussenegger/nvim-dap", -- Debug Adapter Protocol
|
||||
-- "rcarriga/nvim-dap-ui", -- DAP UI components
|
||||
-- "akinsho/toggleterm.nvim", -- Terminal integration
|
||||
-- "nvim-telescope/telescope.nvim", -- For command palette search
|
||||
-- },
|
||||
-- config = function()
|
||||
-- require("intellij").setup({
|
||||
-- -- Theme configuration
|
||||
-- theme = "inherit", -- or "light", "dark"
|
||||
--
|
||||
-- -- Enable verbose logging for debugging
|
||||
-- verbose_logging = false,
|
||||
--
|
||||
-- -- Automatically toggle auto-open main file on start
|
||||
-- auto_open_main_on_start = true,
|
||||
--
|
||||
-- -- Custom actions for your workflow
|
||||
-- custom_actions = {
|
||||
-- {
|
||||
-- name = "Open Project in IntelliJ IDEA",
|
||||
-- action = function()
|
||||
-- vim.fn.system("idea .")
|
||||
-- vim.notify("Opening project in IntelliJ IDEA...")
|
||||
-- end
|
||||
-- },
|
||||
-- {
|
||||
-- name = "Open in VS Code",
|
||||
-- action = function()
|
||||
-- vim.fn.system("code .")
|
||||
-- vim.notify("Opening project in VS Code...")
|
||||
-- end
|
||||
-- },
|
||||
-- {
|
||||
-- name = "Git Status",
|
||||
-- action = function()
|
||||
-- require("toggleterm").exec("git status", 1, 12, "float")
|
||||
-- end
|
||||
-- },
|
||||
-- {
|
||||
-- name = "Git Log",
|
||||
-- action = function()
|
||||
-- require("toggleterm").exec("git log --oneline -10", 1, 12, "float")
|
||||
-- end
|
||||
-- }
|
||||
-- },
|
||||
--
|
||||
-- -- Keymaps for quick access
|
||||
-- keymaps = {
|
||||
-- n = {
|
||||
-- ["<leader>jp"] = function() require('intellij').show_palette() end,
|
||||
-- ["<leader>jd"] = function() require('intellij').show_startup_diagnostics() end,
|
||||
-- ["<leader>jr"] = function() require('intellij').reload() end,
|
||||
-- ["<leader>jv"] = function() require('intellij').toggle_verbose_logging() end,
|
||||
-- },
|
||||
-- v = {
|
||||
-- ["<leader>jt"] = function()
|
||||
-- local start_line = vim.fn.line("'<")
|
||||
-- local end_line = vim.fn.line("'>")
|
||||
-- require("toggleterm").exec("mvn test -Dtest=*#" .. start_line .. "_" .. end_line, 1, 12, "float")
|
||||
-- end
|
||||
-- }
|
||||
-- },
|
||||
--
|
||||
-- -- Project-specific commands based on project type
|
||||
-- project_commands = function(project_type)
|
||||
-- local commands = {}
|
||||
--
|
||||
-- if project_type == "spring-boot" then
|
||||
-- table.insert(commands, {
|
||||
-- name = "Spring Boot DevTools",
|
||||
-- action = function()
|
||||
-- require("toggleterm").exec("mvn spring-boot:run -Dspring-boot.run.profiles=dev", 1, 12, "float")
|
||||
-- end
|
||||
-- })
|
||||
-- table.insert(commands, {
|
||||
-- name = "Spring Boot Actuator Health",
|
||||
-- action = function()
|
||||
-- require("toggleterm").exec("curl -s http://localhost:8080/actuator/health | jq", 1, 12, "float")
|
||||
-- end
|
||||
-- })
|
||||
-- end
|
||||
--
|
||||
-- if project_type == "maven" then
|
||||
-- table.insert(commands, {
|
||||
-- name = "Maven Dependency Tree",
|
||||
-- action = function()
|
||||
-- require("toggleterm").exec("mvn dependency:tree", 1, 12, "float")
|
||||
-- end
|
||||
-- })
|
||||
-- table.insert(commands, {
|
||||
-- name = "Maven Clean Install",
|
||||
-- action = function()
|
||||
-- require("toggleterm").exec("mvn clean install", 1, 12, "float")
|
||||
-- end
|
||||
-- })
|
||||
-- end
|
||||
--
|
||||
-- if project_type == "gradle" then
|
||||
-- table.insert(commands, {
|
||||
-- name = "Gradle Dependencies",
|
||||
-- action = function()
|
||||
-- require("toggleterm").exec("./gradlew dependencies", 1, 12, "float")
|
||||
-- end
|
||||
-- })
|
||||
-- table.insert(commands, {
|
||||
-- name = "Gradle Clean Build",
|
||||
-- action = function()
|
||||
-- require("toggleterm").exec("./gradlew clean build", 1, 12, "float")
|
||||
-- end
|
||||
-- })
|
||||
-- end
|
||||
--
|
||||
-- return commands
|
||||
-- end
|
||||
-- })
|
||||
--
|
||||
-- -- Register hooks for additional functionality
|
||||
-- require("intellij").register_hook("actions", function(project_type)
|
||||
-- local hooks = {}
|
||||
--
|
||||
-- -- Add recent files action
|
||||
-- table.insert(hooks, {
|
||||
-- name = "Recent Java Files",
|
||||
-- action = function()
|
||||
-- local recent_files = require("intellij").get_recent_java_files()
|
||||
-- if #recent_files > 0 then
|
||||
-- vim.ui.select(recent_files, { prompt = "Recent Java Files:" }, function(choice)
|
||||
-- if choice then
|
||||
-- local ok, _ = pcall(vim.cmd, "edit " .. choice)
|
||||
-- if not ok then
|
||||
-- vim.notify("Could not open file: " .. choice, vim.log.levels.WARN, { title = "intellij.nvim" })
|
||||
-- end
|
||||
-- end
|
||||
-- end)
|
||||
-- else
|
||||
-- vim.notify("No recent Java files found")
|
||||
-- end
|
||||
-- end
|
||||
-- })
|
||||
--
|
||||
-- return hooks
|
||||
-- end)
|
||||
--
|
||||
-- -- AUTOMATIC JAVA PROJECT DETECTION AND STARTUP
|
||||
-- local function find_main_java_files()
|
||||
-- local actions = require("intellij.actions")
|
||||
-- local configs = actions.get_run_configs()
|
||||
-- return configs and configs.mains or {}
|
||||
-- end
|
||||
--
|
||||
-- local function is_main_file_open()
|
||||
-- local current_file = vim.api.nvim_buf_get_name(0)
|
||||
-- local main_files = find_main_java_files()
|
||||
--
|
||||
-- for _, main_file in ipairs(main_files) do
|
||||
-- if current_file:match(main_file:gsub("%.", "/") .. "%.java$") then
|
||||
-- return true
|
||||
-- end
|
||||
-- end
|
||||
-- return false
|
||||
-- end
|
||||
--
|
||||
-- local function open_first_main_file()
|
||||
-- local main_files = find_main_java_files()
|
||||
--
|
||||
-- if #main_files > 0 then
|
||||
-- -- Try to find the main file in the project
|
||||
-- local project_root = vim.loop.cwd()
|
||||
-- local found_file = nil
|
||||
--
|
||||
-- -- Debug: show what we're looking for
|
||||
-- vim.notify("Looking for main files: " .. table.concat(main_files, ", "), vim.log.levels.INFO, { title = "intellij.nvim" })
|
||||
--
|
||||
-- for _, main_class in ipairs(main_files) do
|
||||
-- local file_path
|
||||
-- if main_class:match("%.java$") then
|
||||
-- file_path = main_class:gsub("^%./", "")
|
||||
-- else
|
||||
-- file_path = main_class:gsub("%.", "/") .. ".java"
|
||||
-- end
|
||||
--
|
||||
-- local possible_paths = {
|
||||
-- project_root .. "/" .. file_path,
|
||||
-- project_root .. "/src/main/java/" .. file_path,
|
||||
-- project_root .. "/src/java/" .. file_path,
|
||||
-- project_root .. "/src/" .. file_path,
|
||||
-- project_root .. "/app/src/main/java/" .. file_path,
|
||||
-- project_root .. "/main/java/" .. file_path,
|
||||
-- }
|
||||
--
|
||||
-- for _, full_path in ipairs(possible_paths) do
|
||||
-- if vim.fn.filereadable(full_path) == 1 then
|
||||
-- found_file = full_path
|
||||
-- vim.notify("Found main file at: " .. full_path, vim.log.levels.INFO, { title = "intellij.nvim" })
|
||||
-- break
|
||||
-- end
|
||||
-- end
|
||||
--
|
||||
-- if found_file then
|
||||
-- break
|
||||
-- end
|
||||
-- end
|
||||
--
|
||||
-- if found_file then
|
||||
-- local ok, _ = pcall(vim.cmd, "edit " .. found_file)
|
||||
-- if ok then
|
||||
-- vim.notify("Opened main file: " .. found_file, vim.log.levels.INFO, { title = "intellij.nvim" })
|
||||
-- else
|
||||
-- vim.notify("Could not open main file: " .. found_file, vim.log.levels.WARN, { title = "intellij.nvim" })
|
||||
-- end
|
||||
-- return true
|
||||
-- else
|
||||
-- -- Use telescope for better selection if available
|
||||
-- local function select_with_telescope(items, prompt, cb)
|
||||
-- local ok, telescope = pcall(require, 'telescope.builtin')
|
||||
-- if ok then
|
||||
-- telescope.find_files({
|
||||
-- prompt_title = prompt,
|
||||
-- find_command = { 'echo', table.concat(items, '\n') },
|
||||
-- attach_mappings = function(_, map)
|
||||
-- require('telescope.actions').select_default:replace(function()
|
||||
-- local entry = require('telescope.actions.state').get_selected_entry()
|
||||
-- cb(entry.value)
|
||||
-- require('telescope.actions').close(_)
|
||||
-- end)
|
||||
-- return true
|
||||
-- end,
|
||||
-- })
|
||||
-- else
|
||||
-- vim.ui.select(items, { prompt = prompt }, cb)
|
||||
-- end
|
||||
-- end
|
||||
--
|
||||
-- vim.notify("Could not automatically find main files. Showing selection dialog.", vim.log.levels.WARN, { title = "intellij.nvim" })
|
||||
-- select_with_telescope(main_files, "Select main class to open:", function(choice)
|
||||
-- if choice then
|
||||
-- local file_path
|
||||
-- if choice:match("%.java$") then
|
||||
-- file_path = choice:gsub("^%./", "")
|
||||
-- else
|
||||
-- file_path = choice:gsub("%.", "/") .. ".java"
|
||||
-- end
|
||||
--
|
||||
-- local possible_paths = {
|
||||
-- project_root .. "/" .. file_path,
|
||||
-- project_root .. "/src/main/java/" .. file_path,
|
||||
-- project_root .. "/src/java/" .. file_path,
|
||||
-- project_root .. "/src/" .. file_path,
|
||||
-- project_root .. "/app/src/main/java/" .. file_path,
|
||||
-- project_root .. "/main/java/" .. file_path,
|
||||
-- }
|
||||
--
|
||||
-- local found = false
|
||||
-- for _, full_path in ipairs(possible_paths) do
|
||||
-- if vim.fn.filereadable(full_path) == 1 then
|
||||
-- local ok, _ = pcall(vim.cmd, "edit " .. full_path)
|
||||
-- if ok then
|
||||
-- vim.notify("Opened main file: " .. full_path, vim.log.levels.INFO, { title = "intellij.nvim" })
|
||||
-- else
|
||||
-- vim.notify("Could not open main file: " .. full_path, vim.log.levels.WARN, { title = "intellij.nvim" })
|
||||
-- end
|
||||
-- found = true
|
||||
-- break
|
||||
-- end
|
||||
-- end
|
||||
--
|
||||
-- if not found then
|
||||
-- vim.notify("Could not find main file for: " .. choice .. "\nTried paths:\n" .. table.concat(possible_paths, "\n"), vim.log.levels.WARN, { title = "intellij.nvim" })
|
||||
-- end
|
||||
-- end
|
||||
-- end)
|
||||
-- return true
|
||||
-- end
|
||||
-- else
|
||||
-- vim.notify("No main files found in project", vim.log.levels.WARN, { title = "intellij.nvim" })
|
||||
-- end
|
||||
-- return false
|
||||
-- end
|
||||
--
|
||||
-- local function detect_and_start_java_project()
|
||||
-- -- Prevent duplicate detection
|
||||
-- if vim.b.java_project_detected then
|
||||
-- return true
|
||||
-- end
|
||||
--
|
||||
-- local actions = require("intellij.actions")
|
||||
-- local project_type = actions.detect_project_type()
|
||||
--
|
||||
-- if project_type then
|
||||
-- -- Store project info in buffer variables
|
||||
-- vim.b.java_project_type = project_type
|
||||
-- vim.b.java_project_detected = true
|
||||
--
|
||||
-- -- Get JDK and environment info
|
||||
-- local jdk_info = actions.get_jdk_info()
|
||||
-- local env_info = actions.get_env_info()
|
||||
--
|
||||
-- -- Show project detection notification (only once)
|
||||
-- local jdk_version = jdk_info and jdk_info.jdk_version or "unknown"
|
||||
-- vim.notify(
|
||||
-- string.format("Java project detected: %s (JDK: %s)", project_type, jdk_version),
|
||||
-- vim.log.levels.INFO,
|
||||
-- { title = "intellij.nvim", timeout = 3000 }
|
||||
-- )
|
||||
--
|
||||
-- -- Auto-start Java LSP if available (only if not already started)
|
||||
-- if pcall(require, 'jdtls') and not vim.lsp.get_active_clients({ name = 'jdtls' })[1] then
|
||||
-- vim.defer_fn(function()
|
||||
-- -- Try to start LSP safely with error handling
|
||||
-- local ok, result = pcall(vim.cmd, "LspStart jdtls")
|
||||
-- if ok then
|
||||
-- vim.notify("Java LSP started", vim.log.levels.INFO, { title = "intellij.nvim" })
|
||||
--
|
||||
-- -- Add error handler for LSP semantic tokens issues
|
||||
-- vim.api.nvim_create_autocmd("LspAttach", {
|
||||
-- callback = function(args)
|
||||
-- local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
-- if client and client.name == "jdtls" then
|
||||
-- -- Disable semantic tokens if they cause issues
|
||||
-- client.server_capabilities.semanticTokensProvider = nil
|
||||
-- end
|
||||
-- end,
|
||||
-- })
|
||||
-- else
|
||||
-- vim.notify("Java LSP could not be started automatically", vim.log.levels.WARN, { title = "intellij.nvim" })
|
||||
-- end
|
||||
-- end, 1000)
|
||||
-- end
|
||||
--
|
||||
-- -- Auto-compile project on detection (optional)
|
||||
-- if vim.g.auto_compile_java_projects then
|
||||
-- vim.defer_fn(function()
|
||||
-- if project_type == "maven" then
|
||||
-- require("toggleterm").exec("mvn compile", 1, 12, "float")
|
||||
-- elseif project_type == "gradle" then
|
||||
-- require("toggleterm").exec("./gradlew compileJava", 1, 12, "float")
|
||||
-- end
|
||||
-- end, 2000)
|
||||
-- end
|
||||
--
|
||||
-- -- Auto-open main file if not already open
|
||||
-- if vim.g.auto_open_main_file and not is_main_file_open() then
|
||||
-- vim.defer_fn(function()
|
||||
-- open_first_main_file()
|
||||
-- end, 1500)
|
||||
-- end
|
||||
--
|
||||
-- return true
|
||||
-- end
|
||||
-- return false
|
||||
-- end
|
||||
--
|
||||
-- -- Set up autocommands for automatic detection (with debouncing)
|
||||
-- local detection_timer = nil
|
||||
--
|
||||
-- local function debounced_detection()
|
||||
-- if detection_timer then
|
||||
-- vim.loop.timer_stop(detection_timer)
|
||||
-- end
|
||||
-- detection_timer = vim.defer_fn(detect_and_start_java_project, 100)
|
||||
-- end
|
||||
--
|
||||
-- vim.api.nvim_create_autocmd("FileType", {
|
||||
-- pattern = { "java" },
|
||||
-- callback = function()
|
||||
-- -- Auto-detect project type when opening Java files
|
||||
-- debounced_detection()
|
||||
-- end
|
||||
-- })
|
||||
--
|
||||
-- -- Auto-detect when entering directories with Java project files
|
||||
-- vim.api.nvim_create_autocmd("DirChanged", {
|
||||
-- pattern = "*",
|
||||
-- callback = function()
|
||||
-- -- Check if we're in a Java project directory
|
||||
-- if vim.fn.filereadable("pom.xml") == 1 or
|
||||
-- vim.fn.filereadable("build.gradle") == 1 or
|
||||
-- vim.fn.filereadable("build.gradle.kts") == 1 then
|
||||
-- debounced_detection()
|
||||
-- end
|
||||
-- end
|
||||
-- })
|
||||
--
|
||||
-- -- Auto-detect when opening files in Java project directories
|
||||
-- vim.api.nvim_create_autocmd("BufRead", {
|
||||
-- pattern = "*",
|
||||
-- callback = function()
|
||||
-- local cwd = vim.loop.cwd()
|
||||
-- if cwd and (vim.fn.filereadable(cwd .. "/pom.xml") == 1 or
|
||||
-- vim.fn.filereadable(cwd .. "/build.gradle") == 1 or
|
||||
-- vim.fn.filereadable(cwd .. "/build.gradle.kts") == 1) then
|
||||
-- debounced_detection()
|
||||
-- end
|
||||
-- end
|
||||
-- })
|
||||
--
|
||||
-- -- Auto-detect when VimEnter (when Neovim starts)
|
||||
-- vim.api.nvim_create_autocmd("VimEnter", {
|
||||
-- pattern = "*",
|
||||
-- callback = function()
|
||||
-- -- Check if we started in a Java project directory
|
||||
-- local cwd = vim.loop.cwd()
|
||||
-- if cwd and (vim.fn.filereadable(cwd .. "/pom.xml") == 1 or
|
||||
-- vim.fn.filereadable(cwd .. "/build.gradle") == 1 or
|
||||
-- vim.fn.filereadable(cwd .. "/build.gradle.kts") == 1) then
|
||||
-- vim.defer_fn(detect_and_start_java_project, 500)
|
||||
-- end
|
||||
-- end
|
||||
-- })
|
||||
--
|
||||
-- -- Global variable to control auto-compilation
|
||||
-- vim.g.auto_compile_java_projects = true
|
||||
--
|
||||
-- -- Global variable to control auto-opening main files
|
||||
-- vim.g.auto_open_main_file = true
|
||||
--
|
||||
-- -- Add command to toggle auto-compilation
|
||||
-- vim.api.nvim_create_user_command("ToggleJavaAutoCompile", function()
|
||||
-- vim.g.auto_compile_java_projects = not vim.g.auto_compile_java_projects
|
||||
-- vim.notify(
|
||||
-- "Java auto-compilation " .. (vim.g.auto_compile_java_projects and "enabled" or "disabled"),
|
||||
-- vim.log.levels.INFO,
|
||||
-- { title = "intellij.nvim" }
|
||||
-- )
|
||||
-- end, {})
|
||||
--
|
||||
-- -- Add command to clean up cache and temporary files
|
||||
-- vim.api.nvim_create_user_command("IntelliJCleanup", function()
|
||||
-- require("intellij").cleanup()
|
||||
-- end, {})
|
||||
--
|
||||
-- -- Add command to toggle auto-opening main files
|
||||
-- vim.api.nvim_create_user_command("ToggleJavaAutoOpenMain", function()
|
||||
-- vim.g.auto_open_main_file = not vim.g.auto_open_main_file
|
||||
-- vim.notify(
|
||||
-- "Java auto-open main file " .. (vim.g.auto_open_main_file and "enabled" or "disabled"),
|
||||
-- vim.log.levels.INFO,
|
||||
-- { title = "intellij.nvim" }
|
||||
-- )
|
||||
-- end, {})
|
||||
--
|
||||
-- -- Add command to manually open main file
|
||||
-- vim.api.nvim_create_user_command("OpenJavaMainFile", function()
|
||||
-- if open_first_main_file() then
|
||||
-- vim.notify("Main file opened", vim.log.levels.INFO, { title = "intellij.nvim" })
|
||||
-- else
|
||||
-- vim.notify("No main file found in current project", vim.log.levels.WARN, { title = "intellij.nvim" })
|
||||
-- end
|
||||
-- end, {})
|
||||
--
|
||||
-- -- Add command to debug file search
|
||||
-- vim.api.nvim_create_user_command("DebugJavaFileSearch", function()
|
||||
-- local actions = require("intellij.actions")
|
||||
-- local configs = actions.get_run_configs()
|
||||
--
|
||||
-- vim.notify("=== Java File Search Debug ===", vim.log.levels.INFO, { title = "intellij.nvim" })
|
||||
-- vim.notify("Project root: " .. vim.loop.cwd(), vim.log.levels.INFO, { title = "intellij.nvim" })
|
||||
--
|
||||
-- if configs and configs.mains then
|
||||
-- vim.notify("Found main classes: " .. table.concat(configs.mains, ", "), vim.log.levels.INFO, { title = "intellij.nvim" })
|
||||
--
|
||||
-- for _, main_class in ipairs(configs.mains) do
|
||||
-- local file_path = main_class:gsub("%.", "/") .. ".java"
|
||||
-- local project_root = vim.loop.cwd()
|
||||
--
|
||||
-- local possible_paths = {
|
||||
-- project_root .. "/src/main/java/" .. file_path,
|
||||
-- project_root .. "/src/java/" .. file_path,
|
||||
-- project_root .. "/src/" .. file_path,
|
||||
-- project_root .. "/" .. file_path,
|
||||
-- project_root .. "/app/src/main/java/" .. file_path,
|
||||
-- project_root .. "/main/java/" .. file_path,
|
||||
-- }
|
||||
--
|
||||
-- vim.notify("Searching for: " .. main_class, vim.log.levels.INFO, { title = "intellij.nvim" })
|
||||
-- for _, path in ipairs(possible_paths) do
|
||||
-- local exists = vim.fn.filereadable(path) == 1
|
||||
-- vim.notify(" " .. path .. " -> " .. (exists and "EXISTS" or "NOT FOUND"), vim.log.levels.INFO, { title = "intellij.nvim" })
|
||||
-- end
|
||||
-- end
|
||||
-- else
|
||||
-- vim.notify("No main classes found", vim.log.levels.WARN, { title = "intellij.nvim" })
|
||||
-- end
|
||||
-- end, {})
|
||||
--
|
||||
-- -- Add command to manually detect Java project
|
||||
-- vim.api.nvim_create_user_command("DetectJavaProject", function()
|
||||
-- if detect_and_start_java_project() then
|
||||
-- vim.notify("Java project detection completed", vim.log.levels.INFO, { title = "intellij.nvim" })
|
||||
-- else
|
||||
-- vim.notify("No Java project detected in current directory", vim.log.levels.WARN, { title = "intellij.nvim" })
|
||||
-- end
|
||||
-- end, {})
|
||||
--
|
||||
-- -- Check for config flag to auto-toggle main file opening
|
||||
-- if type(require("intellij").opts) == "table" and require("intellij").opts.auto_open_main_on_start then
|
||||
-- vim.g.auto_open_main_file = true
|
||||
-- end
|
||||
-- end
|
||||
-- }
|
||||
@@ -1,6 +1,6 @@
|
||||
return {
|
||||
"neovim/nvim-lspconfig",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
event = { "BufReadPost", "BufNewFile" }, -- Changed from BufReadPre to BufReadPost for better performance
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
{ "antosha417/nvim-lsp-file-operations", config = true },
|
||||
@@ -40,6 +40,7 @@ return {
|
||||
|
||||
local capabilities = cmp_nvim_lsp.default_capabilities()
|
||||
|
||||
-- Enhanced error handling for LSP diagnostics
|
||||
vim.diagnostic.config({
|
||||
signs = {
|
||||
severity = {
|
||||
@@ -52,13 +53,96 @@ return {
|
||||
Info = " ",
|
||||
},
|
||||
},
|
||||
-- Performance optimizations
|
||||
update_in_insert = false, -- Don't update diagnostics in insert mode
|
||||
virtual_text = false, -- Disable virtual text for better performance
|
||||
underline = true, -- Keep underline for errors
|
||||
severity_sort = true, -- Sort diagnostics by severity
|
||||
-- Error handling
|
||||
float = {
|
||||
border = "rounded",
|
||||
source = "always",
|
||||
format = function(diagnostic)
|
||||
if diagnostic.source == "LSP" then
|
||||
return string.format("%s [%s]", diagnostic.message, diagnostic.source)
|
||||
end
|
||||
return diagnostic.message
|
||||
end,
|
||||
},
|
||||
})
|
||||
|
||||
-- File type filtering to prevent LSP errors on non-text files
|
||||
local function should_attach_lsp(client, bufnr)
|
||||
local filetype = vim.api.nvim_buf_get_option(bufnr, "filetype")
|
||||
local filename = vim.api.nvim_buf_get_name(bufnr)
|
||||
|
||||
-- Skip non-text files
|
||||
local non_text_extensions = {
|
||||
"png", "jpg", "jpeg", "gif", "svg", "ico", "bmp", "webp",
|
||||
"mp4", "avi", "mov", "wmv", "flv", "webm", "mkv",
|
||||
"mp3", "wav", "flac", "aac", "ogg",
|
||||
"pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx",
|
||||
"zip", "rar", "7z", "tar", "gz", "bz2",
|
||||
"exe", "dll", "so", "dylib", "bin"
|
||||
}
|
||||
|
||||
for _, ext in ipairs(non_text_extensions) do
|
||||
if filename:match("%." .. ext .. "$") then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- Skip empty or very large files
|
||||
local line_count = vim.api.nvim_buf_line_count(bufnr)
|
||||
if line_count == 0 or line_count > 50000 then
|
||||
return false
|
||||
end
|
||||
|
||||
-- Skip specific file types that don't need LSP
|
||||
local skip_filetypes = {
|
||||
"git", "gitcommit", "gitrebase", "gitconfig",
|
||||
"help", "man", "markdown", "text",
|
||||
"qf", "quickfix", "locationlist",
|
||||
"terminal", "toggleterm"
|
||||
}
|
||||
|
||||
for _, skip_ft in ipairs(skip_filetypes) do
|
||||
if filetype == skip_ft then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local servers = {
|
||||
cssls = {},
|
||||
cssls = {
|
||||
settings = {
|
||||
css = {
|
||||
validate = true,
|
||||
lint = {
|
||||
unknownAtRules = "ignore"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
emmet_ls = {},
|
||||
eslint = {},
|
||||
gopls = {},
|
||||
eslint = {
|
||||
settings = {
|
||||
workingDirectory = { mode = "auto" }
|
||||
}
|
||||
},
|
||||
gopls = {
|
||||
settings = {
|
||||
gopls = {
|
||||
analyses = {
|
||||
unusedparams = true,
|
||||
},
|
||||
staticcheck = true,
|
||||
usePlaceholders = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
graphql = {},
|
||||
html = {},
|
||||
-- jdtls = {}, -- same here
|
||||
@@ -70,11 +154,25 @@ return {
|
||||
library = vim.api.nvim_get_runtime_file("", true),
|
||||
checkThirdParty = false,
|
||||
},
|
||||
-- Performance optimizations
|
||||
telemetry = { enable = false },
|
||||
hint = {
|
||||
enable = false, -- Disable hints for better performance
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
prismals = {},
|
||||
pyright = {},
|
||||
pyright = {
|
||||
settings = {
|
||||
python = {
|
||||
analysis = {
|
||||
typeCheckingMode = "basic", -- Reduce type checking for better performance
|
||||
autoImportCompletions = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
svelte = {},
|
||||
tailwindcss = {},
|
||||
-- Database servers
|
||||
@@ -114,11 +212,69 @@ return {
|
||||
},
|
||||
}
|
||||
|
||||
-- Set up all LSP servers
|
||||
-- Set up all LSP servers with performance optimizations and error handling
|
||||
for server_name, server_config in pairs(servers) do
|
||||
lspconfig[server_name].setup({
|
||||
capabilities = capabilities,
|
||||
settings = server_config.settings or {},
|
||||
-- Performance optimizations
|
||||
flags = {
|
||||
debounce_text_changes = 150, -- Debounce text changes
|
||||
},
|
||||
-- Enhanced error handling and file filtering
|
||||
on_attach = function(client, bufnr)
|
||||
-- Only attach LSP if it's appropriate for this file
|
||||
if not should_attach_lsp(client, bufnr) then
|
||||
client.stop()
|
||||
return
|
||||
end
|
||||
|
||||
-- Add error handling for LSP operations
|
||||
local function safe_lsp_call(func, ...)
|
||||
local success, result = pcall(func, ...)
|
||||
if not success then
|
||||
vim.notify("LSP error: " .. tostring(result), vim.log.levels.WARN)
|
||||
return nil
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
-- Override LSP methods with error handling
|
||||
local original_request = client.request
|
||||
client.request = function(method, params, handler, bufnr)
|
||||
-- Skip requests for non-text files
|
||||
if not should_attach_lsp(client, bufnr or 0) then
|
||||
return
|
||||
end
|
||||
|
||||
-- Add timeout to prevent hanging
|
||||
local timeout_id = vim.defer_fn(function()
|
||||
if handler then
|
||||
handler(nil, { message = "LSP request timed out" })
|
||||
end
|
||||
end, 5000) -- 5 second timeout
|
||||
|
||||
-- Wrap the original request
|
||||
local wrapped_handler = handler and function(...)
|
||||
vim.loop.timer_stop(timeout_id)
|
||||
handler(...)
|
||||
end
|
||||
|
||||
return original_request(method, params, wrapped_handler, bufnr)
|
||||
end
|
||||
end,
|
||||
-- Reduce diagnostic frequency
|
||||
handlers = {
|
||||
["textDocument/publishDiagnostics"] = vim.lsp.with(
|
||||
vim.lsp.diagnostic.on_publish_diagnostics,
|
||||
{
|
||||
virtual_text = false,
|
||||
signs = true,
|
||||
underline = true,
|
||||
update_in_insert = false,
|
||||
}
|
||||
),
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
@@ -131,13 +287,52 @@ return {
|
||||
capabilities = capabilities,
|
||||
})
|
||||
|
||||
-- Set up TypeScript Tools
|
||||
-- Set up TypeScript Tools with performance optimizations and error handling
|
||||
require("typescript-tools").setup({
|
||||
settings = {
|
||||
tsserver_plugins = {},
|
||||
tsserver_file_preferences = {},
|
||||
tsserver_format_options = {},
|
||||
-- Performance optimizations
|
||||
tsserver_max_tsc_memory = 4096, -- Limit memory usage
|
||||
tsserver_experimental_enableProjectDiagnostics = false, -- Disable project diagnostics for better performance
|
||||
},
|
||||
-- Add error handling for TypeScript Tools
|
||||
on_attach = function(client, bufnr)
|
||||
if not should_attach_lsp(client, bufnr) then
|
||||
client.stop()
|
||||
return
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Global LSP error handling
|
||||
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(
|
||||
vim.lsp.handlers.hover,
|
||||
{ border = "rounded" }
|
||||
)
|
||||
|
||||
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(
|
||||
vim.lsp.handlers.signature_help,
|
||||
{ border = "rounded" }
|
||||
)
|
||||
|
||||
-- Handle LSP errors gracefully
|
||||
vim.lsp.set_log_level("warn") -- Reduce log verbosity
|
||||
|
||||
-- Add autocmd to handle LSP errors
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(args)
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
if client then
|
||||
-- Add error handling for this client
|
||||
client.notify("workspace/didChangeConfiguration", {
|
||||
settings = {
|
||||
-- Add any client-specific error handling settings here
|
||||
}
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ return {
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-buffer", -- source for text in buffer
|
||||
"hrsh7th/cmp-path", -- source for file system paths
|
||||
"hrsh7th/cmp-nvim-lsp", -- LSP completion source
|
||||
{
|
||||
"L3MON4D3/LuaSnip",
|
||||
-- follow latest release.
|
||||
@@ -28,6 +29,9 @@ return {
|
||||
cmp.setup({
|
||||
completion = {
|
||||
completeopt = "menu,menuone,preview,noselect",
|
||||
-- Performance optimizations
|
||||
keyword_length = 2, -- Start completion after 2 characters
|
||||
keyword_pattern = [[\%(-\?\d\+\%(\.\d\+\)\?\|\h\w*\%(-\w*\)*\)]], -- Better keyword pattern
|
||||
},
|
||||
snippet = { -- configure how nvim-cmp interacts with snippet engine
|
||||
expand = function(args)
|
||||
@@ -46,10 +50,10 @@ return {
|
||||
}),
|
||||
-- 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 = "nvim_lsp", priority = 1000},
|
||||
{ name = "luasnip", priority = 750 }, -- snippets
|
||||
{ name = "buffer", priority = 500, keyword_length = 3 }, -- text within current buffer
|
||||
{ name = "path", priority = 250 }, -- file system paths
|
||||
}),
|
||||
|
||||
-- configure lspkind for vs-code like pictograms in completion menu
|
||||
@@ -59,6 +63,27 @@ return {
|
||||
ellipsis_char = "...",
|
||||
}),
|
||||
},
|
||||
|
||||
-- Performance optimizations
|
||||
performance = {
|
||||
debounce = 50, -- Debounce completion requests
|
||||
throttle = 100, -- Throttle completion requests
|
||||
fetching_timeout = 200, -- Timeout for fetching completions
|
||||
},
|
||||
|
||||
-- Reduce completion menu size for better performance
|
||||
window = {
|
||||
completion = {
|
||||
border = "rounded",
|
||||
scrollbar = false,
|
||||
col_offset = -3,
|
||||
side_padding = 0,
|
||||
},
|
||||
documentation = {
|
||||
border = "rounded",
|
||||
scrollbar = false,
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
||||
@@ -23,9 +23,70 @@ return {
|
||||
end,
|
||||
})
|
||||
|
||||
-- File filtering function to prevent LSP errors and image freezing
|
||||
local function filter_files(entry)
|
||||
local filename = entry.filename or entry.value
|
||||
if not filename then return true end
|
||||
|
||||
-- Skip non-text files that can cause LSP errors or freezing
|
||||
local skip_extensions = {
|
||||
-- Images
|
||||
"png", "jpg", "jpeg", "gif", "svg", "ico", "bmp", "webp", "tiff", "tga",
|
||||
-- Videos
|
||||
"mp4", "avi", "mov", "wmv", "flv", "webm", "mkv", "m4v", "3gp",
|
||||
-- Audio
|
||||
"mp3", "wav", "flac", "aac", "ogg", "m4a", "wma",
|
||||
-- Documents
|
||||
"pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "odt", "ods", "odp",
|
||||
-- Archives
|
||||
"zip", "rar", "7z", "tar", "gz", "bz2", "xz", "lzma",
|
||||
-- Binaries
|
||||
"exe", "dll", "so", "dylib", "bin", "app", "dmg", "deb", "rpm",
|
||||
-- Other problematic files
|
||||
"lock", "log", "tmp", "temp", "cache", "bak", "backup"
|
||||
}
|
||||
|
||||
for _, ext in ipairs(skip_extensions) do
|
||||
if filename:match("%." .. ext .. "$") then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- Skip hidden files and directories (except .git)
|
||||
if filename:match("/%.") and not filename:match("/%.git/") then
|
||||
return false
|
||||
end
|
||||
|
||||
-- Skip node_modules and other heavy directories
|
||||
if filename:match("/node_modules/") or
|
||||
filename:match("/vendor/") or
|
||||
filename:match("/%.git/") or
|
||||
filename:match("/dist/") or
|
||||
filename:match("/build/") or
|
||||
filename:match("/target/") then
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
telescope.setup({
|
||||
defaults = {
|
||||
path_display = { "smart" },
|
||||
-- Performance optimizations
|
||||
cache_picker = {
|
||||
num_pickers = -1,
|
||||
},
|
||||
-- Enhanced preview with file filtering
|
||||
preview = {
|
||||
treesitter = false, -- Disable treesitter in preview for better performance
|
||||
timeout = 100, -- Reduce preview timeout
|
||||
},
|
||||
-- Optimize sorting
|
||||
sorting_strategy = "ascending",
|
||||
-- Add file filtering to all pickers
|
||||
file_sorter = require("telescope.sorters").get_fuzzy_file,
|
||||
generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter,
|
||||
mappings = {
|
||||
i = {
|
||||
["<C-k>"] = actions.move_selection_previous, -- move to prev result
|
||||
@@ -38,11 +99,41 @@ return {
|
||||
pickers = {
|
||||
find_files = {
|
||||
hidden = true,
|
||||
-- Performance optimizations
|
||||
find_command = { "rg", "--files", "--hidden", "--glob", "!**/.git/*" },
|
||||
no_ignore = false,
|
||||
follow = false, -- Don't follow symlinks for better performance
|
||||
-- Add file filtering
|
||||
file_filter = filter_files,
|
||||
},
|
||||
live_grep = {
|
||||
additional_args = function()
|
||||
return { "--hidden" }
|
||||
end,
|
||||
-- Performance optimizations
|
||||
glob_pattern = { "!**/.git/*", "!**/node_modules/*", "!**/vendor/*" },
|
||||
previewer = false, -- Disable previewer for live_grep for better performance
|
||||
-- Add file filtering for grep
|
||||
file_filter = filter_files,
|
||||
},
|
||||
-- Optimize other pickers
|
||||
buffers = {
|
||||
sort_lastused = true,
|
||||
ignore_current_buffer = true,
|
||||
},
|
||||
git_files = {
|
||||
git_command = { "git", "ls-files", "--exclude-standard" },
|
||||
-- Add file filtering for git files
|
||||
file_filter = filter_files,
|
||||
},
|
||||
},
|
||||
-- Performance optimizations
|
||||
extensions = {
|
||||
fzf = {
|
||||
fuzzy = true,
|
||||
override_generic_sorter = true,
|
||||
override_file_sorter = true,
|
||||
case_mode = "smart_case",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
return {
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
event = { "BufReadPost", "BufNewFile" }, -- Changed from BufReadPre to BufReadPost for better performance
|
||||
build = ":TSUpdate",
|
||||
dependencies = {
|
||||
"windwp/nvim-ts-autotag",
|
||||
@@ -17,6 +17,9 @@ return {
|
||||
-- Prevent Treesitter from parsing Copilot files
|
||||
return lang == "copilot" or vim.api.nvim_buf_get_name(buf):match("copilot.lua")
|
||||
end,
|
||||
-- Performance optimizations
|
||||
use_languagetree = true,
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
-- enable indentation
|
||||
indent = { enable = true },
|
||||
@@ -58,6 +61,13 @@ return {
|
||||
node_decremental = "<bs>",
|
||||
},
|
||||
},
|
||||
-- Performance optimizations
|
||||
playground = {
|
||||
enable = false, -- Disable playground for better performance
|
||||
},
|
||||
query_linter = {
|
||||
enable = false, -- Disable query linter for better performance
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ return {
|
||||
event = "VeryLazy",
|
||||
init = function()
|
||||
vim.o.timeout = true
|
||||
vim.o.timeoutlen = 500
|
||||
vim.o.timeoutlen = 200 -- Reduced from 500 for faster response
|
||||
end,
|
||||
opts = {
|
||||
-- your configuration comes here
|
||||
|
||||
Reference in New Issue
Block a user