add config

This commit is contained in:
nik
2025-10-05 16:58:08 +03:00
parent 61fc1ec1ba
commit 6b1626bb41
19 changed files with 1022 additions and 0 deletions

78
ftplugin/cs.lua Normal file
View File

@@ -0,0 +1,78 @@
-- C# specific settings and commands
vim.opt_local.tabstop = 4
vim.opt_local.shiftwidth = 4
vim.opt_local.expandtab = true
vim.opt_local.softtabstop = 4
-- C# specific commands
vim.api.nvim_create_user_command("CSharpBuild", function()
vim.cmd("!dotnet build")
end, { desc = "Build C# project with dotnet" })
vim.api.nvim_create_user_command("CSharpRun", function()
vim.cmd("!dotnet run")
end, { desc = "Run C# project with dotnet" })
vim.api.nvim_create_user_command("CSharpTest", function()
vim.cmd("!dotnet test")
end, { desc = "Run C# tests with dotnet" })
vim.api.nvim_create_user_command("CSharpRestore", function()
vim.cmd("!dotnet restore")
end, { desc = "Restore C# project dependencies" })
vim.api.nvim_create_user_command("CSharpClean", function()
vim.cmd("!dotnet clean")
end, { desc = "Clean C# project build artifacts" })
-- New project templates
vim.api.nvim_create_user_command("CSharpNewConsole", function()
local name = vim.fn.input("Project name: ")
if name ~= "" then
vim.cmd("!dotnet new console -n " .. name)
end
end, { desc = "Create new C# console application" })
vim.api.nvim_create_user_command("CSharpNewClassLib", function()
local name = vim.fn.input("Project name: ")
if name ~= "" then
vim.cmd("!dotnet new classlib -n " .. name)
end
end, { desc = "Create new C# class library" })
-- Quick snippets
local opts = { noremap = true, silent = true, buffer = true }
-- Console.WriteLine snippet
vim.keymap.set("n", "<leader>cw", "oConsole.WriteLine();<Esc>hi", opts)
vim.keymap.set("i", "cw", "Console.WriteLine();<Esc>hi", opts)
-- Main method snippet
vim.keymap.set("n", "<leader>cm", function()
local lines = {
"static void Main(string[] args)",
"{",
" ",
"}",
}
vim.api.nvim_put(lines, "l", true, true)
vim.cmd("normal! 2j$")
end, opts)
-- Class template snippet
vim.keymap.set("n", "<leader>cc", function()
local filename = vim.fn.expand("%:t:r")
local class_name = filename:gsub("^%l", string.upper)
local lines = {
"namespace " .. vim.fn.fnamemodify(vim.fn.getcwd(), ":t"),
"{",
" public class " .. class_name,
" {",
" ",
" }",
"}",
}
vim.api.nvim_put(lines, "l", true, true)
vim.cmd("normal! 4j$")
end, opts)

31
ftplugin/java.lua Normal file
View File

@@ -0,0 +1,31 @@
-- Simplified debug info that doesn't rely on mason-registry
local function inspect_jdtls_installation()
local mason_path = vim.fn.stdpath "data" .. "/mason"
local jdtls_path = mason_path .. "/packages/jdtls"
print("JDTLS package path: " .. jdtls_path)
local launcher_jar = vim.fn.glob(jdtls_path .. "/plugins/org.eclipse.equinox.launcher_*.jar")
print("Launcher JAR: " .. (launcher_jar ~= "" and launcher_jar or "NOT FOUND"))
local config_dir = jdtls_path .. "/config_linux"
if vim.fn.has "mac" == 1 then
config_dir = jdtls_path .. "/config_mac"
elseif vim.fn.has "win32" == 1 then
config_dir = jdtls_path .. "/config_win"
end
print("Config dir: " .. (vim.fn.isdirectory(config_dir) == 1 and config_dir or "NOT FOUND"))
end
-- Call this before setting up jdtls
inspect_jdtls_installation()
-- Then setup as usual
require("configs.java").setup()
-- Use pcall to safely require jdtls module
local status, _ = pcall(require, "jdtls")
if status then
require("configs.java").setup_jdtls()
else
print "JDTLS module not found. Make sure nvim-jdtls is installed."
end