feat: restructure keymaps and fix Lua configuration
- Restructure keymaps into modular folder system - Create keymaps/ folder with organized files - Separate keymaps by category (general, personal, lsp, telescope, plugins) - Auto-loading system for better maintainability - Fix Lua configuration issues - Add compatibility layer for deprecated APIs - Fix snacks.nvim configuration - Disable latex support in render-markdown - Improve LSP configuration - Enhance function navigation - Restore and improve LSP keymaps - Add comprehensive Telescope integration - Fix conflicting keymaps - Improve overall Neovim setup - Better options configuration - Enhanced plugin configurations - Cleaner code organization
This commit is contained in:
@@ -29,7 +29,31 @@ return {
|
||||
"hrsh7th/nvim-cmp", -- autocompletion for avante commands and mentions
|
||||
"ibhagwan/fzf-lua", -- for file_selector provider fzf
|
||||
"stevearc/dressing.nvim", -- for input provider dressing
|
||||
"folke/snacks.nvim", -- for input provider snacks
|
||||
{
|
||||
"folke/snacks.nvim", -- for input provider snacks
|
||||
lazy = false,
|
||||
priority = 1000,
|
||||
config = function()
|
||||
require("snacks").setup({
|
||||
-- Enable all snacks modules
|
||||
bigfile = { enabled = true },
|
||||
dashboard = { enabled = true },
|
||||
explorer = { enabled = true },
|
||||
image = { enabled = true },
|
||||
input = { enabled = true },
|
||||
lazygit = { enabled = true },
|
||||
notifier = { enabled = true },
|
||||
picker = { enabled = true },
|
||||
quickfile = { enabled = true },
|
||||
scope = { enabled = true },
|
||||
scroll = { enabled = true },
|
||||
statuscolumn = { enabled = true },
|
||||
terminal = { enabled = true },
|
||||
toggle = { enabled = true },
|
||||
words = { enabled = true },
|
||||
})
|
||||
end,
|
||||
},
|
||||
"nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons
|
||||
{
|
||||
"HakonHarnes/img-clip.nvim", -- Image pasting support
|
||||
@@ -52,6 +76,7 @@ return {
|
||||
config = function()
|
||||
require("render-markdown").setup({
|
||||
file_types = { "markdown", "Avante" },
|
||||
latex = { enabled = false }, -- Disable latex to avoid warning
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
@@ -1,10 +1,26 @@
|
||||
return {
|
||||
--[[ dir = "/Users/carlos/Documents/SSD_Documents/personals/ideaDrop", ]]
|
||||
--[[dir = "/Volumes/Carlos_SSD/Documents/projects/ideaDrop",]]
|
||||
"CarGDev/ideadrop.nvim",
|
||||
name = "ideaDrop",
|
||||
dependencies = {
|
||||
"nvim-tree/nvim-tree.lua",
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
},
|
||||
config = function()
|
||||
require("ideaDrop").setup({
|
||||
idea_dir = "/Users/carlos/Nextcloud/ObsidianVault",
|
||||
})
|
||||
|
||||
-- Set up convenient keymaps for ideaDrop
|
||||
vim.keymap.set("n", "<leader>id", ":IdeaRight<CR>", { desc = "Open today's idea in right buffer" })
|
||||
vim.keymap.set("n", "<leader>in", ":IdeaRight ", { desc = "Open named idea in right buffer" })
|
||||
vim.keymap.set("n", "<leader>it", ":IdeaTree<CR>", { desc = "Open idea tree browser" })
|
||||
vim.keymap.set("n", "<leader>is", ":IdeaSearch ", { desc = "Search ideas" })
|
||||
vim.keymap.set("n", "<leader>ig", ":IdeaTags<CR>", { desc = "Browse tags" })
|
||||
vim.keymap.set("n", "<leader>if", ":Idea<CR>", { desc = "Open today's idea in float" })
|
||||
|
||||
-- Optional: Override the default :Idea command to use right buffer instead of float
|
||||
-- Uncomment the line below if you want :Idea to always use the right buffer
|
||||
-- vim.api.nvim_create_user_command("Idea", function(opts) vim.cmd("IdeaRight " .. (opts.args or "")) end, { nargs = "?" })
|
||||
end,
|
||||
}
|
||||
|
||||
504
lua/cargdev/plugins/intellij.lua
Normal file
504
lua/cargdev/plugins/intellij.lua
Normal file
@@ -0,0 +1,504 @@
|
||||
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
|
||||
}
|
||||
@@ -14,7 +14,6 @@ return {
|
||||
local lspconfig = require("lspconfig")
|
||||
local mason_lspconfig = require("mason-lspconfig")
|
||||
local cmp_nvim_lsp = require("cmp_nvim_lsp")
|
||||
local keymap = vim.keymap
|
||||
|
||||
mason_lspconfig.setup({
|
||||
ensure_installed = {
|
||||
@@ -24,7 +23,7 @@ return {
|
||||
"gopls",
|
||||
"graphql",
|
||||
"html",
|
||||
-- "jdtls", -- uncomment if you’re actively doing Java
|
||||
-- "jdtls", -- uncomment if you're actively doing Java
|
||||
"lua_ls",
|
||||
"prismals",
|
||||
"pyright",
|
||||
@@ -41,10 +40,10 @@ return {
|
||||
min = vim.diagnostic.severity.WARN,
|
||||
},
|
||||
icons = {
|
||||
Error = " ",
|
||||
Warn = " ",
|
||||
Error = " ",
|
||||
Warn = " ",
|
||||
Hint = " ",
|
||||
Info = " ",
|
||||
Info = " ",
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -89,39 +88,7 @@ return {
|
||||
-- }
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
|
||||
callback = function(ev)
|
||||
local opts = { buffer = ev.buf, silent = true }
|
||||
local mappings = {
|
||||
["gR"] = { "<cmd>Telescope lsp_references<CR>", "Show LSP references" },
|
||||
["gD"] = { vim.lsp.buf.declaration, "Go to declaration" },
|
||||
["gd"] = { "<cmd>Telescope lsp_definitions<CR>", "Show LSP definitions" },
|
||||
["gi"] = { "<cmd>Telescope lsp_implementations<CR>", "Show LSP implementations" },
|
||||
["gt"] = { "<cmd>Telescope lsp_type_definitions<CR>", "Show LSP type definitions" },
|
||||
["<leader>ca"] = { vim.lsp.buf.code_action, "See available code actions" },
|
||||
["<leader>rn"] = { vim.lsp.buf.rename, "Smart rename" },
|
||||
["<leader>D"] = { "<cmd>Telescope diagnostics bufnr=0<CR>", "Show buffer diagnostics" },
|
||||
["<leader>dd"] = { vim.diagnostic.open_float, "Show line diagnostics" },
|
||||
["[d"] = { vim.diagnostic.goto_prev, "Go to previous diagnostic" },
|
||||
["]d"] = { vim.diagnostic.goto_next, "Go to next diagnostic" },
|
||||
["K"] = { vim.lsp.buf.hover, "Show documentation for cursor" },
|
||||
["<leader>rs"] = { ":LspRestart<CR>", "Restart LSP" },
|
||||
}
|
||||
|
||||
for key, map in pairs(mappings) do
|
||||
keymap.set("n", key, map[1], { desc = map[2], silent = true })
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
buffer = ev.buf,
|
||||
callback = function()
|
||||
vim.diagnostic.open_float(nil, { focusable = false })
|
||||
end,
|
||||
})
|
||||
|
||||
vim.o.updatetime = 250
|
||||
end,
|
||||
})
|
||||
-- LSP keymaps are now handled in the main keymaps.lua file
|
||||
-- This ensures consistent keymaps across all file types
|
||||
end,
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ return {
|
||||
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
"folke/todo-comments.nvim",
|
||||
"nvim-telescope/telescope-dap.nvim",
|
||||
"nvim-telescope/telescope-session-lens.nvim",
|
||||
},
|
||||
config = function()
|
||||
local telescope = require("telescope")
|
||||
@@ -34,17 +36,53 @@ return {
|
||||
},
|
||||
},
|
||||
},
|
||||
pickers = {
|
||||
find_files = {
|
||||
hidden = true,
|
||||
},
|
||||
live_grep = {
|
||||
additional_args = function()
|
||||
return { "--hidden" }
|
||||
end,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- Load extensions
|
||||
telescope.load_extension("fzf")
|
||||
telescope.load_extension("dap")
|
||||
telescope.load_extension("session-lens")
|
||||
|
||||
-- set keymaps
|
||||
local keymap = vim.keymap -- for conciseness
|
||||
|
||||
-- File navigation
|
||||
keymap.set("n", "<leader>ff", "<cmd>Telescope find_files<cr>", { desc = "Fuzzy find files in cwd" })
|
||||
keymap.set("n", "<leader>fr", "<cmd>Telescope oldfiles<cr>", { desc = "Fuzzy find recent files" })
|
||||
keymap.set("n", "<leader>fs", "<cmd>Telescope live_grep<cr>", { desc = "Find string in cwd" })
|
||||
keymap.set("n", "<leader>fc", "<cmd>Telescope grep_string<cr>", { desc = "Find string under cursor in cwd" })
|
||||
keymap.set("n", "<leader>ft", "<cmd>TodoTelescope<cr>", { desc = "Find todos" })
|
||||
|
||||
-- LSP navigation (these work when LSP is attached)
|
||||
keymap.set("n", "<leader>fd", "<cmd>Telescope lsp_definitions<cr>", { desc = "Go to definition" })
|
||||
keymap.set("n", "<leader>fi", "<cmd>Telescope lsp_implementations<cr>", { desc = "Go to implementation" })
|
||||
keymap.set("n", "<leader>fr", "<cmd>Telescope lsp_references<cr>", { desc = "Show references" })
|
||||
keymap.set("n", "<leader>ft", "<cmd>Telescope lsp_type_definitions<cr>", { desc = "Go to type definition" })
|
||||
keymap.set("n", "<leader>fs", "<cmd>Telescope lsp_document_symbols<cr>", { desc = "Document symbols" })
|
||||
keymap.set("n", "<leader>fw", "<cmd>Telescope lsp_workspace_symbols<cr>", { desc = "Workspace symbols" })
|
||||
keymap.set("n", "<leader>fd", "<cmd>Telescope diagnostics<cr>", { desc = "Show diagnostics" })
|
||||
|
||||
-- Buffer and session management
|
||||
keymap.set("n", "<leader>fb", "<cmd>Telescope buffers<cr>", { desc = "Find buffers" })
|
||||
keymap.set("n", "<leader>fh", "<cmd>Telescope help_tags<cr>", { desc = "Help tags" })
|
||||
keymap.set("n", "<leader>fm", "<cmd>Telescope marks<cr>", { desc = "Find marks" })
|
||||
keymap.set("n", "<leader>fk", "<cmd>Telescope keymaps<cr>", { desc = "Find keymaps" })
|
||||
keymap.set("n", "<leader>fc", "<cmd>Telescope commands<cr>", { desc = "Find commands" })
|
||||
|
||||
-- Git
|
||||
keymap.set("n", "<leader>fg", "<cmd>Telescope git_commits<cr>", { desc = "Git commits" })
|
||||
keymap.set("n", "<leader>fG", "<cmd>Telescope git_bcommits<cr>", { desc = "Git buffer commits" })
|
||||
keymap.set("n", "<leader>fb", "<cmd>Telescope git_branches<cr>", { desc = "Git branches" })
|
||||
keymap.set("n", "<leader>fs", "<cmd>Telescope git_status<cr>", { desc = "Git status" })
|
||||
end,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user