The infamous windows/linux NVIM config
This commit is contained in:
@@ -16,7 +16,6 @@ require("globals")
|
|||||||
require("mappings")
|
require("mappings")
|
||||||
require("autocmd")
|
require("autocmd")
|
||||||
require("minimodules").load_modules()
|
require("minimodules").load_modules()
|
||||||
-- require("coc-settings")
|
|
||||||
|
|
||||||
if vim.g.neovide then
|
if vim.g.neovide then
|
||||||
require("config.neovide")
|
require("config.neovide")
|
||||||
|
|||||||
+3
-3
@@ -2,15 +2,15 @@ local autocmd = vim.api.nvim_create_autocmd
|
|||||||
|
|
||||||
autocmd("LspAttach", {
|
autocmd("LspAttach", {
|
||||||
callback = function(args)
|
callback = function(args)
|
||||||
local client = vim.lsp.get_client_by_id( args.data.client_id )
|
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||||
if client then
|
if client and vim.lsp.document_color and vim.lsp.document_color.enable then
|
||||||
vim.lsp.document_color.enable(false, args.buf, { "background" })
|
vim.lsp.document_color.enable(false, args.buf, { "background" })
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
autocmd("VimLeave", {
|
autocmd("VimLeave", {
|
||||||
command = "set guicursor=a:ver25-Cursor"
|
command = "set guicursor=a:ver25-Cursor",
|
||||||
})
|
})
|
||||||
|
|
||||||
autocmd("BufWritePre", {
|
autocmd("BufWritePre", {
|
||||||
|
|||||||
@@ -0,0 +1,238 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
M.plugin = {
|
||||||
|
"sbdchd/neoformat",
|
||||||
|
event = { "BufReadPre", "BufNewFile" },
|
||||||
|
config = function()
|
||||||
|
-- === formatter enablement (order = priority) ===
|
||||||
|
vim.g.neoformat_enabled_lua = { "stylua" }
|
||||||
|
vim.g.neoformat_enabled_python = { "black" }
|
||||||
|
vim.g.neoformat_enabled_javascript = { "prettier" }
|
||||||
|
vim.g.neoformat_enabled_typescript = { "prettier" }
|
||||||
|
vim.g.neoformat_enabled_qml = { "qmlformat" }
|
||||||
|
vim.g.neoformat_enabled_go = { "gofmt" }
|
||||||
|
vim.g.neoformat_enabled_sh = { "shfmt" }
|
||||||
|
vim.g.neoformat_enabled_bash = { "shfmt" }
|
||||||
|
vim.g.neoformat_enabled_zsh = { "shfmt" }
|
||||||
|
vim.g.neoformat_enabled_powershell = { "pwshfmt" } -- experimental
|
||||||
|
|
||||||
|
-- === helper to prefer local prettier in cwd/node_modules/.bin ===
|
||||||
|
local function prefer_local_prettier()
|
||||||
|
local cwd = vim.fn.getcwd()
|
||||||
|
local local_path = cwd .. "/node_modules/.bin/prettier"
|
||||||
|
if vim.loop.fs_stat(local_path) then
|
||||||
|
return local_path
|
||||||
|
end
|
||||||
|
local global = vim.fn.exepath("prettier")
|
||||||
|
if global ~= "" then
|
||||||
|
return global
|
||||||
|
end
|
||||||
|
return "prettier"
|
||||||
|
end
|
||||||
|
|
||||||
|
-- === neoformatters definitions ===
|
||||||
|
vim.g.neoformatters_javascript = {
|
||||||
|
prettier = {
|
||||||
|
exe = prefer_local_prettier(),
|
||||||
|
args = { "--stdin-filepath", "%:p" },
|
||||||
|
stdin = 1,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
vim.g.neoformatters_typescript = vim.g.neoformatters_javascript
|
||||||
|
vim.g.neoformatters_json = vim.g.neoformatters_javascript
|
||||||
|
vim.g.neoformatters_markdown = vim.g.neoformatters_javascript
|
||||||
|
|
||||||
|
vim.g.neoformatters_lua = {
|
||||||
|
stylua = {
|
||||||
|
exe = "stylua",
|
||||||
|
args = { "-", "--stdin-filepath", "%:p" },
|
||||||
|
stdin = 1,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.g.neoformatters_python = {
|
||||||
|
black = {
|
||||||
|
exe = "black",
|
||||||
|
args = { "-" },
|
||||||
|
stdin = 1,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.g.neoformatters_qml = {
|
||||||
|
qmlformat = {
|
||||||
|
exe = "qmlformat",
|
||||||
|
args = { "-" },
|
||||||
|
stdin = 1,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.g.neoformatters_go = {
|
||||||
|
gofmt = {
|
||||||
|
exe = "gofmt",
|
||||||
|
args = {},
|
||||||
|
stdin = 1,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.g.neoformatters_sh = {
|
||||||
|
shfmt = {
|
||||||
|
exe = "shfmt",
|
||||||
|
args = { "-i", "2", "-ci" },
|
||||||
|
stdin = 1,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
vim.g.neoformatters_bash = vim.g.neoformatters_sh
|
||||||
|
vim.g.neoformatters_zsh = vim.g.neoformatters_sh
|
||||||
|
|
||||||
|
vim.g.neoformatters_powershell = {
|
||||||
|
pwshfmt = {
|
||||||
|
exe = "pwsh",
|
||||||
|
args = {
|
||||||
|
"-NoProfile",
|
||||||
|
"-Command",
|
||||||
|
[[
|
||||||
|
$in = [Console]::In.ReadToEnd();
|
||||||
|
if (Get-Command Invoke-Formatter -ErrorAction SilentlyContinue) {
|
||||||
|
Invoke-Formatter -ScriptDefinition $in | Out-String
|
||||||
|
} else {
|
||||||
|
$in
|
||||||
|
}
|
||||||
|
]],
|
||||||
|
},
|
||||||
|
stdin = 1,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
-- === utility: check whether a path/exe exists ===
|
||||||
|
local function is_executable(path)
|
||||||
|
if not path or path == "" then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
-- if it contains a slash or backslash, treat as path
|
||||||
|
if path:match("[/\\]") then
|
||||||
|
local stat = vim.loop.fs_stat(path)
|
||||||
|
return stat and stat.type == "file"
|
||||||
|
end
|
||||||
|
-- otherwise check PATH
|
||||||
|
return vim.fn.exepath(path) ~= ""
|
||||||
|
end
|
||||||
|
|
||||||
|
local function resolve_exe_field(exe_field)
|
||||||
|
if type(exe_field) == "function" then
|
||||||
|
local ok, res = pcall(exe_field)
|
||||||
|
if ok then
|
||||||
|
return res
|
||||||
|
else
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if type(exe_field) == "string" then
|
||||||
|
return exe_field
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- === determine whether any configured formatter for ft is available ===
|
||||||
|
local function has_formatter_for_ft(ft)
|
||||||
|
if not ft or ft == "" then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 1) check explicit enabled list first
|
||||||
|
local enabled_var = "neoformat_enabled_" .. ft
|
||||||
|
local enabled = vim.g[enabled_var]
|
||||||
|
local candidates = {}
|
||||||
|
|
||||||
|
if enabled then
|
||||||
|
if type(enabled) == "string" then
|
||||||
|
candidates = { enabled }
|
||||||
|
elseif type(enabled) == "table" then
|
||||||
|
candidates = enabled
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- 2) fallback to any entries defined in vim.g.neoformatters_<ft>
|
||||||
|
local table_var = "neoformatters_" .. ft
|
||||||
|
local tbl = vim.g[table_var]
|
||||||
|
if type(tbl) == "table" then
|
||||||
|
for name, _ in pairs(tbl) do
|
||||||
|
table.insert(candidates, name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if #candidates == 0 then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
-- table of custom formatter definitions
|
||||||
|
local formatter_table = vim.g["neoformatters_" .. ft]
|
||||||
|
|
||||||
|
for _, name in ipairs(candidates) do
|
||||||
|
-- if we have a definition with exe, check that exe
|
||||||
|
if formatter_table and formatter_table[name] and formatter_table[name].exe then
|
||||||
|
local exe_field = formatter_table[name].exe
|
||||||
|
local exe = resolve_exe_field(exe_field)
|
||||||
|
if exe and is_executable(exe) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- otherwise, try to find a system executable by the formatter name
|
||||||
|
if is_executable(name) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
-- === safe format wrapper that no-ops when no formatter found ===
|
||||||
|
local function neoformat_if_available(bufnr)
|
||||||
|
bufnr = bufnr or 0
|
||||||
|
local ft = vim.bo[bufnr].filetype
|
||||||
|
if not has_formatter_for_ft(ft) then
|
||||||
|
-- silent fallback: do nothing if no formatter is available
|
||||||
|
return
|
||||||
|
end
|
||||||
|
-- run Neoformat in protected call to avoid blocking save on errors
|
||||||
|
pcall(vim.cmd, "Neoformat")
|
||||||
|
end
|
||||||
|
|
||||||
|
-- === keymap and command using the safe wrapper ===
|
||||||
|
vim.keymap.set("n", "<leader>f", function()
|
||||||
|
neoformat_if_available()
|
||||||
|
end, { noremap = true, silent = true })
|
||||||
|
|
||||||
|
vim.api.nvim_create_user_command("NeoformatIfAvailable", function()
|
||||||
|
neoformat_if_available()
|
||||||
|
end, {})
|
||||||
|
|
||||||
|
-- === autoreformat on save (uses safe wrapper) ===
|
||||||
|
local format_on_save_filetypes = {
|
||||||
|
lua = true,
|
||||||
|
python = true,
|
||||||
|
javascript = true,
|
||||||
|
typescript = true,
|
||||||
|
qml = true,
|
||||||
|
go = true,
|
||||||
|
sh = true,
|
||||||
|
bash = true,
|
||||||
|
zsh = true,
|
||||||
|
powershell = false, -- keep off by default (experimental)
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||||
|
group = vim.api.nvim_create_augroup("NeoformatOnSave", { clear = true }),
|
||||||
|
callback = function(args)
|
||||||
|
local ft = vim.bo[args.buf].filetype
|
||||||
|
if format_on_save_filetypes[ft] then
|
||||||
|
neoformat_if_available(args.buf)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- === end config ===
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
return M
|
||||||
+2
-1
@@ -5,6 +5,7 @@ vim.opt.softtabstop = 4
|
|||||||
vim.opt.shiftwidth = 4
|
vim.opt.shiftwidth = 4
|
||||||
vim.opt.expandtab = false
|
vim.opt.expandtab = false
|
||||||
vim.opt.smartindent = false
|
vim.opt.smartindent = false
|
||||||
|
--vim.opt.rocks.enabled = false
|
||||||
|
|
||||||
vim.o.list = true
|
vim.o.list = true
|
||||||
vim.opt.listchars = { tab = "··", trail = "·", nbsp = "_" }
|
vim.opt.listchars = { tab = "··", trail = "·", nbsp = "_" }
|
||||||
@@ -13,7 +14,7 @@ vim.opt.wrap = true
|
|||||||
vim.opt.linebreak = true
|
vim.opt.linebreak = true
|
||||||
vim.opt.swapfile = false
|
vim.opt.swapfile = false
|
||||||
vim.opt.backup = false
|
vim.opt.backup = false
|
||||||
vim.opt.undodir = os.getenv("HOME") .. "/.nvim/undodir"
|
vim.opt.undodir = vim.fn.stdpath('data') .. '/undodir'
|
||||||
vim.opt.undofile = true
|
vim.opt.undofile = true
|
||||||
vim.opt.hlsearch = false
|
vim.opt.hlsearch = false
|
||||||
vim.opt.incsearch = true
|
vim.opt.incsearch = true
|
||||||
|
|||||||
+16
-54
@@ -32,22 +32,6 @@ return {
|
|||||||
require("config.autosession")
|
require("config.autosession")
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"olimorris/onedarkpro.nvim",
|
|
||||||
priority = 1000,
|
|
||||||
config = function()
|
|
||||||
require("config.themelight")
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"nvim-telescope/telescope.nvim",
|
|
||||||
dependencies = {
|
|
||||||
"nvim-lua/plenary.nvim",
|
|
||||||
},
|
|
||||||
config = function()
|
|
||||||
require("config.telescope")
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"lambdalisue/vim-suda",
|
"lambdalisue/vim-suda",
|
||||||
init = function()
|
init = function()
|
||||||
@@ -148,14 +132,14 @@ return {
|
|||||||
{
|
{
|
||||||
"notken12/base46-colors",
|
"notken12/base46-colors",
|
||||||
},
|
},
|
||||||
-- {
|
{
|
||||||
-- "mason-org/mason-lspconfig.nvim",
|
"mason-org/mason-lspconfig.nvim",
|
||||||
-- opts = {},
|
-- opts = {},
|
||||||
-- dependencies = {
|
-- dependencies = {
|
||||||
-- { "mason-org/mason.nvim", opts = {} },
|
-- { "mason-org/mason.nvim", opts = {} },
|
||||||
-- "neovim/nvim-lspconfig",
|
-- "neovim/nvim-lspconfig",
|
||||||
-- },
|
-- },
|
||||||
-- },
|
},
|
||||||
{
|
{
|
||||||
"folke/lazydev.nvim",
|
"folke/lazydev.nvim",
|
||||||
ft = "lua",
|
ft = "lua",
|
||||||
@@ -197,16 +181,6 @@ return {
|
|||||||
{
|
{
|
||||||
"mfussenegger/nvim-jdtls",
|
"mfussenegger/nvim-jdtls",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"ThePrimeagen/harpoon",
|
|
||||||
branch = "harpoon2",
|
|
||||||
dependencies = {
|
|
||||||
"nvim-lua/plenary.nvim",
|
|
||||||
},
|
|
||||||
config = function()
|
|
||||||
require("config.harpoon")
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"catgoose/nvim-colorizer.lua",
|
"catgoose/nvim-colorizer.lua",
|
||||||
config = function()
|
config = function()
|
||||||
@@ -255,28 +229,6 @@ return {
|
|||||||
vim.g.minimal_italic_functions = true
|
vim.g.minimal_italic_functions = true
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"propet/colorscheme-persist.nvim",
|
|
||||||
dependencies = {
|
|
||||||
"nvim-telescope/telescope.nvim",
|
|
||||||
},
|
|
||||||
lazy = false,
|
|
||||||
config = true,
|
|
||||||
keys = {
|
|
||||||
{
|
|
||||||
"<leader>sp",
|
|
||||||
function()
|
|
||||||
require("colorscheme-persist").picker()
|
|
||||||
end,
|
|
||||||
mode = "n",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
opts = {
|
|
||||||
picker_opts = require("telescope.themes").get_dropdown({
|
|
||||||
enable_preview = true,
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"aserowy/tmux.nvim",
|
"aserowy/tmux.nvim",
|
||||||
config = function()
|
config = function()
|
||||||
@@ -289,6 +241,16 @@ return {
|
|||||||
require("config.TID")
|
require("config.TID")
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"ThePrimeagen/harpoon",
|
||||||
|
branch = "harpoon2",
|
||||||
|
dependencies = {
|
||||||
|
"nvim-lua/plenary.nvim",
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
require("config.harpoon")
|
||||||
|
end,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"aznhe21/actions-preview.nvim",
|
"aznhe21/actions-preview.nvim",
|
||||||
config = function()
|
config = function()
|
||||||
@@ -297,9 +259,9 @@ return {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"sbdchd/neoformat",
|
"sbdchd/neoformat",
|
||||||
-- config = function()
|
config = function()
|
||||||
-- require("config.neoformat")
|
require("config.neoformat")
|
||||||
-- end,
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Zacharias-Brohn/zterm-navigator.nvim",
|
"Zacharias-Brohn/zterm-navigator.nvim",
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
"nvim-telescope/telescope.nvim",
|
||||||
|
dependencies = {
|
||||||
|
"nvim-lua/plenary.nvim",
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
require("config.telescope")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"propet/colorscheme-persist.nvim",
|
||||||
|
enable = false,
|
||||||
|
dependencies = {
|
||||||
|
"nvim-telescope/telescope.nvim",
|
||||||
|
},
|
||||||
|
lazy = false,
|
||||||
|
config = true,
|
||||||
|
keys = {
|
||||||
|
{
|
||||||
|
"<leader>sp",
|
||||||
|
function()
|
||||||
|
require("colorscheme-persist").picker()
|
||||||
|
end,
|
||||||
|
mode = "n",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
opts = function() -- ✅ Changed to function
|
||||||
|
return {
|
||||||
|
picker_opts = require("telescope.themes").get_dropdown({
|
||||||
|
enable_preview = true,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
"olimorris/onedarkpro.nvim",
|
||||||
|
priority = 1000,
|
||||||
|
config = function()
|
||||||
|
require("config.themelight")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
Write-Host "installing required packages for nvim" -foregroundcolor cyan
|
||||||
|
|
||||||
|
$packages = @(
|
||||||
|
"Neovim.Neovim",
|
||||||
|
"MartinStorsjo.LLVM-MinGW.MSVCRT",
|
||||||
|
"zig.zig",
|
||||||
|
"GnuWin32.Make",
|
||||||
|
"Rustlang.Rust.MSVC",
|
||||||
|
"GoLang.Go",
|
||||||
|
"Kitware.Cmake",
|
||||||
|
"Ninja-build.Ninja"
|
||||||
|
)
|
||||||
|
|
||||||
|
foreach ( $package in $packages ) {
|
||||||
|
Write-Host "Installing $package..." -foregroundcolor yellow
|
||||||
|
# winget install $package
|
||||||
|
}
|
||||||
|
|
||||||
|
$list = @(
|
||||||
|
"Git.Git",
|
||||||
|
"ajeetdsouza.zoxide",
|
||||||
|
)
|
||||||
|
|
||||||
|
Write-Host "Module list" -ForegroundColor Magenta
|
||||||
|
for ($i = 0; $i -lt $list.Count; $i++) {
|
||||||
|
$index = $i + 1
|
||||||
|
Write-Host "$index) $($list[$i])" -ForegroundColor Magenta
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Do you want to install the above modules for PowerShell (y/n)? " -ForegroundColor Green -NoNewLine
|
||||||
|
$answer = Read-Host
|
||||||
|
|
||||||
|
if ($answer -eq 'y' -or $answer -eq 'Y') {
|
||||||
|
foreach ($module in $list) {
|
||||||
|
Write-Host "Installing $module..." -ForegroundColor Yellow
|
||||||
|
# winget install --id $module -e
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user