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

24
LICENSE Normal file
View File

@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <https://unlicense.org>

View File

@@ -0,0 +1 @@
this is my neovim configuration

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

37
init.lua Normal file
View File

@@ -0,0 +1,37 @@
vim.g.base46_cache = vim.fn.stdpath "data" .. "/base46/"
vim.g.mapleader = " "
-- bootstrap lazy and all plugins
local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim"
if not vim.uv.fs_stat(lazypath) then
local repo = "https://github.com/folke/lazy.nvim.git"
vim.fn.system { "git", "clone", "--filter=blob:none", repo, "--branch=stable", lazypath }
end
vim.opt.rtp:prepend(lazypath)
local lazy_config = require "configs.lazy"
-- load plugins
require("lazy").setup({
{
"NvChad/NvChad",
lazy = false,
branch = "v2.5",
import = "nvchad.plugins",
},
{ import = "plugins" },
}, lazy_config)
-- load theme
dofile(vim.g.base46_cache .. "defaults")
dofile(vim.g.base46_cache .. "statusline")
require "options"
require "nvchad.autocmds"
vim.schedule(function()
require "mappings"
end)

31
lazy-lock.json Normal file
View File

@@ -0,0 +1,31 @@
{
"LuaSnip": { "branch": "master", "commit": "21f74f7ba8c49f95f9d7c8293b147c2901dd2d3a" },
"NvChad": { "branch": "v2.5", "commit": "29ebe31ea6a4edf351968c76a93285e6e108ea08" },
"base46": { "branch": "v3.0", "commit": "0094095ed60aa55f7148bc1e783b0156f3e7f4f8" },
"blink.cmp": { "branch": "main", "commit": "bae4bae0eedd1fa55f34b685862e94a222d5c6f8" },
"conform.nvim": { "branch": "master", "commit": "b4aab989db276993ea5dcb78872be494ce546521" },
"friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" },
"gitsigns.nvim": { "branch": "main", "commit": "6e3c66548035e50db7bd8e360a29aec6620c3641" },
"indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" },
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "5e085efe67fccb13372d54331d849219662a7e93" },
"mason.nvim": { "branch": "main", "commit": "7dc4facca9702f95353d5a1f87daf23d78e31c2a" },
"menu": { "branch": "main", "commit": "7a0a4a2896b715c066cfbe320bdc048091874cc6" },
"minty": { "branch": "main", "commit": "aafc9e8e0afe6bf57580858a2849578d8d8db9e0" },
"nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" },
"nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" },
"nvim-dap": { "branch": "master", "commit": "7891b01beedc37cef4eaf2e92563bd0a5b6e9c58" },
"nvim-dap-python": { "branch": "master", "commit": "030385d03363988370adaa5cf21fa465daddb088" },
"nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" },
"nvim-jdtls": { "branch": "master", "commit": "8dbecd3fc86b4fc4120087767deab4604880d751" },
"nvim-lspconfig": { "branch": "master", "commit": "3e89e4973d784e1c966517e528b3a30395403fa7" },
"nvim-tree.lua": { "branch": "master", "commit": "fefa335f1c8f690eb668a1efd18ee4fc6d64cd3e" },
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
"nvim-web-devicons": { "branch": "master", "commit": "6e51ca170563330e063720449c21f43e27ca0bc1" },
"omnisharp-extended-lsp.nvim": { "branch": "main", "commit": "ec1a2431f8872f650a85ed71c24f0715df2e49c2" },
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
"telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" },
"ui": { "branch": "v3.0", "commit": "4852e04faefbba3a18cb197b76ac00f4bc2e615f" },
"volt": { "branch": "main", "commit": "7b8c5e790120d9f08c8487dcb80692db6d2087a1" },
"which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" }
}

24
lua/chadrc.lua Normal file
View File

@@ -0,0 +1,24 @@
-- This file needs to have same structure as nvconfig.lua
-- https://github.com/NvChad/ui/blob/v3.0/lua/nvconfig.lua
-- Please read that file to know all available options :(
---@type ChadrcConfig
local M = {}
M.base46 = {
theme = "ashes",
-- hl_override = {
-- Comment = { italic = true },
-- ["@comment"] = { italic = true },
-- },
}
-- M.nvdash = { load_on_startup = true }
-- M.ui = {
-- tabufline = {
-- lazyload = false
-- }
--}
return M

29
lua/configs/conform.lua Normal file
View File

@@ -0,0 +1,29 @@
local conform = require("conform")
local options = {
formatters_by_ft = {
lua = { "stylua" },
css = { "prettier" },
html = { "prettier" },
javascript = { "prettier" },
javascriptreact = { "prettier" },
typescript = { "prettier" },
typescriptreact = { "prettier" },
json = { "prettier" },
-- Add C++ formatters
cpp = { "clang-format" },
c = { "clang-format" },
python = { "black", "isort" },
cs = { "csharpier" },
},
format_on_save = {
-- These options will be passed to conform.format()
timeout_ms = 500,
lsp_fallback = true,
},
}
return options

19
lua/configs/cpp.lua Normal file
View File

@@ -0,0 +1,19 @@
local M = {}
M.setup = function()
-- Any specific C++ settings can go here
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true
-- For C++ projects, you might want to set up a compile command
vim.api.nvim_create_user_command("CppBuild", function()
vim.cmd("!g++ -std=c++17 % -o %:r")
end, {})
vim.api.nvim_create_user_command("CppRun", function()
vim.cmd("!g++ -std=c++17 % -o %:r && ./%:r")
end, {})
end
return M

23
lua/configs/csharp.lua Normal file
View File

@@ -0,0 +1,23 @@
local M = {}
M.setup = function()
local dap = require("dap")
dap.adapters.coreclr = {
type = "executable",
command = "netcoredbg",
args = { "--interpreter=vscode" },
}
dap.configurations = dap.configurations or {}
dap.configurations.cs = {
{
type = "coreclr",
name = "launch",
request = "launch",
program = function()
return vim.fn.input("Path to dll: ", vim.fn.getcwd() .. "/bin/Debug/net8.0/", "file")
end,
},
}
end
return M

130
lua/configs/java.lua Normal file
View File

@@ -0,0 +1,130 @@
local M = {}
M.setup = function()
-- Java-specific settings
vim.opt_local.tabstop = 4
vim.opt_local.shiftwidth = 4
vim.opt_local.expandtab = true
-- Quick commands for Java
vim.api.nvim_create_user_command("JavaRun", function()
vim.cmd "!javac % && java %:r"
end, {})
vim.api.nvim_create_user_command("JavaCompile", function()
vim.cmd "!javac %"
end, {})
end
-- Setup jdtls when a Java file is opened
M.setup_jdtls = function()
local status, jdtls = pcall(require, "jdtls")
if not status then
print "Failed to load JDTLS plugin"
return
end
-- Find root of project
local root_markers = { ".git", "mvnw", "gradlew", "pom.xml", "build.gradle" }
local root_dir = require("jdtls.setup").find_root(root_markers)
if not root_dir then
root_dir = vim.fn.getcwd()
end
-- Determine OS-specific config
local os_config
if vim.fn.has "mac" == 1 then
os_config = "config_mac"
elseif vim.fn.has "unix" == 1 then
os_config = "config_linux"
elseif vim.fn.has "win32" == 1 then
os_config = "config_win"
else
os_config = "config_linux"
end
-- Get mason paths
local mason_path = vim.fn.stdpath "data" .. "/mason"
local jdtls_path = mason_path .. "/packages/jdtls"
-- Check if launcher jar exists
local launcher_jar = vim.fn.glob(jdtls_path .. "/plugins/org.eclipse.equinox.launcher_*.jar")
if launcher_jar == "" then
print "JDTLS launcher jar not found"
return
end
-- Create workspace directory
local project_name = vim.fn.fnamemodify(root_dir, ":p:h:t")
local workspace_dir = vim.fn.expand "~/.cache/jdtls/workspace/" .. project_name
vim.fn.mkdir(workspace_dir, "p")
-- Get system Java
local java_cmd = "java"
local config = {
cmd = {
java_cmd,
"-Declipse.application=org.eclipse.jdt.ls.core.id1",
"-Dosgi.bundles.defaultStartLevel=4",
"-Declipse.product=org.eclipse.jdt.ls.core.product",
"-Dlog.protocol=true",
"-Dlog.level=ALL",
"-Xms1g",
"--add-modules=ALL-SYSTEM",
"--add-opens",
"java.base/java.util=ALL-UNNAMED",
"--add-opens",
"java.base/java.lang=ALL-UNNAMED",
"-jar",
launcher_jar,
"-configuration",
jdtls_path .. "/" .. os_config,
"-data",
workspace_dir,
},
root_dir = root_dir,
settings = {
java = {
signatureHelp = { enabled = true },
contentProvider = { preferred = "fernflower" },
completion = {
favoriteStaticMembers = {
"org.junit.jupiter.api.Assertions.*",
"java.util.Objects.requireNonNull",
"java.util.Objects.requireNonNullElse",
},
},
sources = {
organizeImports = {
starThreshold = 9999,
staticStarThreshold = 9999,
},
},
codeGeneration = {
toString = {
template = "${object.className}{${member.name()}=${member.value}, ${otherMembers}}",
},
useBlocks = true,
},
configuration = {
updateBuildConfiguration = "interactive",
},
},
},
capabilities = require("nvchad.configs.lspconfig").capabilities,
on_attach = require("nvchad.configs.lspconfig").on_attach,
init_options = {
bundles = {},
},
}
-- Print the commands being used (for debugging)
print("JDTLS launcher: " .. launcher_jar)
print("JDTLS config dir: " .. jdtls_path .. "/" .. os_config)
-- Start jdtls
jdtls.start_or_attach(config)
end
return M

47
lua/configs/lazy.lua Normal file
View File

@@ -0,0 +1,47 @@
return {
defaults = { lazy = true },
install = { colorscheme = { "nvchad" } },
ui = {
icons = {
ft = "",
lazy = "󰂠 ",
loaded = "",
not_loaded = "",
},
},
performance = {
rtp = {
disabled_plugins = {
"2html_plugin",
"tohtml",
"getscript",
"getscriptPlugin",
"gzip",
"logipat",
"netrw",
"netrwPlugin",
"netrwSettings",
"netrwFileHandlers",
"matchit",
"tar",
"tarPlugin",
"rrhelper",
"spellfile_plugin",
"vimball",
"vimballPlugin",
"zip",
"zipPlugin",
"tutor",
"rplugin",
"syntax",
"synmenu",
"optwin",
"compiler",
"bugreport",
"ftplugin",
},
},
},
}

226
lua/configs/lspconfig.lua Normal file
View File

@@ -0,0 +1,226 @@
local on_attach = require("nvchad.configs.lspconfig").on_attach
local capabilities = require("nvchad.configs.lspconfig").capabilities
local lspconfig = require("lspconfig")
-- List of servers to install and configure
local servers = {
"lua_ls",
"clangd",
"pyright",
"ts_ls", -- TypeScript/JavaScript
"html",
"cssls",
"emmet_ls",
"eslint",
}
-- Loop through servers and set them up
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup({
on_attach = on_attach,
capabilities = capabilities,
})
end
-- C++ specific configuration
lspconfig.clangd.setup({
on_attach = on_attach,
capabilities = capabilities,
cmd = {
"clangd",
"--background-index",
"--suggest-missing-includes",
"--clang-tidy",
"--header-insertion=iwyu",
},
filetypes = { "c", "cpp", "objc", "objcpp" },
})
-- Python specific configuration
lspconfig.pyright.setup({
on_attach = on_attach,
capabilities = capabilities,
settings = {
pyright = {
autoImportCompletions = true,
typeCheckingMode = "basic", -- or "strict"
},
python = {
analysis = {
diagnosticSeverityOverrides = {
-- Customize diagnostic severity if needed
},
},
},
},
})
lspconfig.ts_ls.setup({
on_attach = on_attach,
capabilities = capabilities,
init_options = {
preferences = {
disableSuggestions = false,
},
},
settings = {
typescript = {
inlayHints = {
includeInlayParameterNameHints = "all",
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = true,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayEnumMemberValueHints = true,
},
},
javascript = {
inlayHints = {
includeInlayParameterNameHints = "all",
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = true,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayEnumMemberValueHints = true,
},
},
},
})
-- HTML configuration
lspconfig.html.setup({
on_attach = on_attach,
capabilities = capabilities,
filetypes = { "html", "htmldjango" },
})
-- CSS configuration
lspconfig.cssls.setup({
on_attach = on_attach,
capabilities = capabilities,
settings = {
css = {
validate = true,
lint = {
unknownAtRules = "ignore",
},
},
scss = {
validate = true,
lint = {
unknownAtRules = "ignore",
},
},
less = {
validate = true,
lint = {
unknownAtRules = "ignore",
},
},
},
})
-- Emmet configuration for HTML/CSS
lspconfig.emmet_ls.setup({
on_attach = on_attach,
capabilities = capabilities,
filetypes = { "html", "css", "scss", "javascript", "javascriptreact", "typescript", "typescriptreact" },
init_options = {
html = {
options = {
["bem.enabled"] = true,
},
},
},
})
-- ESLint configuration
lspconfig.eslint.setup({
on_attach = function(client, bufnr)
on_attach(client, bufnr)
-- Auto fix on save
vim.api.nvim_create_autocmd("BufWritePre", {
buffer = bufnr,
command = "EslintFixAll",
})
end,
capabilities = capabilities,
settings = {
codeAction = {
disableRuleComment = {
enable = true,
location = "separateLine",
},
showDocumentation = {
enable = true,
},
},
codeActionOnSave = {
enable = false,
mode = "all",
},
format = true,
nodePath = "",
onIgnoredFiles = "off",
packageManager = "npm",
quiet = false,
rulesCustomizations = {},
run = "onType",
useESLintClass = false,
validate = "on",
workingDirectory = {
mode = "location",
},
},
})
-- Configure tinymist (Typst LSP)
lspconfig.tinymist.setup({
cmd = { vim.fn.stdpath("data") .. "/mason/bin/tinymist" },
on_attach = on_attach,
capabilities = capabilities,
filetypes = { "typ", "typst" },
})
-- C# OmniSharp configuration - SINGLE CONFIGURATION
lspconfig.omnisharp.setup({
on_attach = function(client, bufnr)
on_attach(client, bufnr)
-- Set up C# specific keymaps
local opts = { noremap = true, silent = true, buffer = bufnr }
vim.keymap.set("n", "gd", require("omnisharp_extended").lsp_definitions, opts)
vim.keymap.set("n", "gr", require("omnisharp_extended").lsp_references, opts)
vim.keymap.set("n", "gi", require("omnisharp_extended").lsp_implementation, opts)
end,
capabilities = capabilities,
handlers = {
["textDocument/definition"] = require("omnisharp_extended").handler,
},
cmd = { "omnisharp", "--languageserver", "--hostPID", tostring(vim.fn.getpid()) },
root_dir = function(fname)
return require("lspconfig.util").root_pattern("*.sln", "*.csproj", "omnisharp.json", "function.json")(fname)
or require("lspconfig.util").find_git_ancestor(fname)
or vim.fn.getcwd()
end,
settings = {
FormattingOptions = {
EnableEditorConfigSupport = true,
OrganizeImports = true,
},
MsBuild = {
LoadProjectsOnDemand = false,
},
RoslynExtensionsOptions = {
EnableAnalyzersSupport = true,
EnableImportCompletion = true,
AnalyzeOpenDocumentsOnly = false,
},
Sdk = {
IncludePrereleases = true,
},
},
})

34
lua/configs/python.lua Normal file
View File

@@ -0,0 +1,34 @@
local M = {}
M.setup = function()
-- Python-specific settings
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true
-- Quick run and lint commands
vim.api.nvim_create_user_command("PythonRun", function()
vim.cmd("!python3 %")
end, {})
vim.api.nvim_create_user_command("PythonLint", function()
vim.cmd("!flake8 %")
end, {})
-- Optional: Virtual environment detection
local function activate_venv()
local venv_path = vim.fn.getcwd() .. "/venv/bin/activate"
if vim.fn.filereadable(venv_path) == 1 then
vim.env.VIRTUAL_ENV = venv_path
vim.cmd("source " .. venv_path)
end
end
-- Try to activate virtual environment when opening Python file
vim.api.nvim_create_autocmd("FileType", {
pattern = "python",
callback = activate_venv
})
end
return M

21
lua/configs/tinymist.lua Normal file
View File

@@ -0,0 +1,21 @@
local M = {}
M.setup = function()
local lspconfig = require("lspconfig")
lspconfig.tinymist.setup {
cmd = { vim.fn.stdpath("data") .. "/mason/bin/tinymist" },
on_attach = require("nvchad.configs.lspconfig").on_attach,
capabilities = require("nvchad.configs.lspconfig").capabilities,
filetypes = { "typ", "typst" },
settings = {
export = {
pdf = "onSave", -- or "onType", "never"
png = "never",
},
-- Other tinymist specific settings
},
}
end
return M

103
lua/configs/webdev.lua Normal file
View File

@@ -0,0 +1,103 @@
-- Create: lua/configs/webdev.lua
local M = {}
M.setup = function()
-- Web development settings
vim.api.nvim_create_autocmd("FileType", {
pattern = { "html", "css", "javascript", "typescript", "json" },
callback = function()
vim.opt_local.tabstop = 2
vim.opt_local.shiftwidth = 2
vim.opt_local.expandtab = true
vim.opt_local.softtabstop = 2
end,
})
-- Quick commands for web development
vim.api.nvim_create_user_command("NodeRun", function()
vim.cmd("!node %")
end, { desc = "Run current JavaScript file with Node.js" })
vim.api.nvim_create_user_command("LiveServer", function()
-- This assumes you have live-server installed globally
-- npm install -g live-server
vim.cmd("!live-server .")
end, { desc = "Start live server in current directory" })
-- HTML5 template insertion
vim.api.nvim_create_user_command("HTMLTemplate", function()
local template = {
"<!DOCTYPE html>",
"<html lang=\"en\">",
"<head>",
" <meta charset=\"UTF-8\">",
" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">",
" <title>Document</title>",
"</head>",
"<body>",
" ",
"</body>",
"</html>"
}
vim.api.nvim_put(template, "l", true, true)
end, { desc = "Insert HTML5 template" })
-- React component template
vim.api.nvim_create_user_command("ReactComponent", function()
local filename = vim.fn.expand("%:t:r")
local component_name = filename:gsub("^%l", string.upper)
local template = {
"import React from 'react';",
"",
"const " .. component_name .. " = () => {",
" return (",
" <div>",
" <h1>" .. component_name .. "</h1>",
" </div>",
" );",
"};",
"",
"export default " .. component_name .. ";"
}
vim.api.nvim_put(template, "l", true, true)
end, { desc = "Insert React component template" })
-- Package.json quick commands
vim.api.nvim_create_user_command("NpmInit", function()
vim.cmd("!npm init -y")
end, { desc = "Initialize package.json" })
vim.api.nvim_create_user_command("NpmInstall", function()
vim.cmd("!npm install")
end, { desc = "Install npm dependencies" })
vim.api.nvim_create_user_command("NpmDev", function()
vim.cmd("!npm run dev")
end, { desc = "Run npm dev script" })
vim.api.nvim_create_user_command("NpmBuild", function()
vim.cmd("!npm run build")
end, { desc = "Run npm build script" })
-- Set up some useful keymaps for web development
vim.api.nvim_create_autocmd("FileType", {
pattern = { "html", "css", "javascript", "typescript", "javascriptreact", "typescriptreact" },
callback = function()
local opts = { noremap = true, silent = true, buffer = true }
-- Console.log snippet for JS/TS files
if vim.bo.filetype == "javascript" or vim.bo.filetype == "typescript" then
vim.keymap.set("n", "<leader>cl", "oconsole.log();<Esc>hi", opts)
vim.keymap.set("i", "clog", "console.log();<Esc>hi", opts)
end
-- Quick tag closing for HTML
if vim.bo.filetype == "html" then
vim.keymap.set("i", ">>", "></<C-x><C-o>", opts)
end
end,
})
end
return M

10
lua/mappings.lua Normal file
View File

@@ -0,0 +1,10 @@
require "nvchad.mappings"
-- add yours here
local map = vim.keymap.set
map("n", ";", ":", { desc = "CMD enter command mode" })
map("i", "jk", "<ESC>")
-- map({ "n", "i", "v" }, "<C-s>", "<cmd> w <cr>")

16
lua/options.lua Normal file
View File

@@ -0,0 +1,16 @@
require("nvchad.options")
require("configs.cpp").setup()
require("configs.python").setup()
-- Add to the end of your options.lua
-- require("configs.typst").setup()
-- Add near the top
-- require("configs.typst-lsp").setup()
--
require("configs.webdev").setup() -- Add this line
require("configs.tinymist").setup()
require("configs.csharp").setup()
-- add yours here!
-- local o = vim.o
-- o.cursorlineopt ='both' -- to enable cursorline!

138
lua/plugins/init.lua Normal file
View File

@@ -0,0 +1,138 @@
return {
{
"stevearc/conform.nvim",
event = "BufWritePre", -- uncomment for format on save
opts = require("configs.conform"),
},
{
"neovim/nvim-lspconfig",
config = function()
require("configs.lspconfig")
end,
},
{ import = "nvchad.blink.lazyspec" },
{
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = {
"vim",
"lua",
"vimdoc",
"html",
"css",
"python",
"typst",
"c_sharp", -- C# treesitter support
"cpp",
"c",
"javascript",
"typescript",
"json",
},
},
},
{
"williamboman/mason.nvim",
opts = {
ensure_installed = {
-- LSP servers
"clangd",
"typescript-language-server",
"html-lsp",
"css-lsp",
"emmet-ls",
"eslint-lsp",
"pyright",
"tinymist",
"jdtls",
"omnisharp", -- C# LSP server
-- Formatters
"prettier",
"eslint_d",
"black", -- Python formatter
"isort",
"google-java-format",
"csharpier", -- C# formatter
-- Debuggers
"netcoredbg", -- C# debugger
-- Linters
"flake8",
},
},
},
{
"williamboman/mason-lspconfig.nvim",
dependencies = {
"williamboman/mason.nvim",
},
opts = {
ensure_installed = {
"clangd",
"pyright",
"jdtls",
"ts_ls",
"html",
"cssls",
"emmet_ls",
"eslint",
"omnisharp", -- Ensure OmniSharp is installed
},
automatic_installation = true,
},
},
-- C# specific plugins
{
"Hoffs/omnisharp-extended-lsp.nvim",
ft = "cs", -- Only load for C# files
},
-- Debug support
{
"mfussenegger/nvim-dap",
dependencies = {
"rcarriga/nvim-dap-ui",
},
config = function()
require("configs.csharp") -- This will set up C# debugging
end,
},
-- Python debugging
{
"mfussenegger/nvim-dap-python",
ft = "python",
dependencies = {
"mfussenegger/nvim-dap",
"rcarriga/nvim-dap-ui",
},
config = function()
local path = require("mason-registry").get_package("debugpy"):get_install_path()
require("dap-python").setup(path .. "/venv/bin/python")
end,
},
-- Java support
{
"mfussenegger/nvim-jdtls",
ft = "java",
},
-- Enhanced completion
{
"hrsh7th/nvim-cmp",
opts = function()
local M = require("nvchad.configs.cmp")
table.insert(M.sources, { name = "pyright" })
return M
end,
},
}