poggers
This commit is contained in:
@@ -0,0 +1,177 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
local icons = require("assets.icons").icons.kinds
|
||||||
|
|
||||||
|
local devicons = {
|
||||||
|
default_icon = { icon = "", name = "Default" },
|
||||||
|
js = { icon = "", name = "js" },
|
||||||
|
ts = { icon = "", name = "ts" },
|
||||||
|
lock = { icon = "", name = "lock" },
|
||||||
|
["robots.txt"] = { icon = "", name = "robots" },
|
||||||
|
}
|
||||||
|
|
||||||
|
M.components = {
|
||||||
|
kind_icon = {
|
||||||
|
text = function(ctx)
|
||||||
|
local icon = (icons[ctx.kind] or "")
|
||||||
|
|
||||||
|
return icon .. " "
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
kind = {
|
||||||
|
highlight = function(ctx)
|
||||||
|
return ctx.kind
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
local opts = {
|
||||||
|
"saghen/blink.cmp",
|
||||||
|
dependencies = {
|
||||||
|
"rafamadriz/friendly-snippets",
|
||||||
|
{
|
||||||
|
"fang2hou/blink-copilot",
|
||||||
|
config = function()
|
||||||
|
require "config.blink-copilot"
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
version = "1.*",
|
||||||
|
|
||||||
|
opts = {
|
||||||
|
keymap = {
|
||||||
|
["<Tab>"] = {
|
||||||
|
function(cmp)
|
||||||
|
if cmp.is_visible() then
|
||||||
|
return cmp.select_next()
|
||||||
|
end
|
||||||
|
|
||||||
|
if cmp.snippet_active() then
|
||||||
|
return cmp.snippet_forward()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
"fallback",
|
||||||
|
},
|
||||||
|
["<S-Tab>"] = {
|
||||||
|
function(cmp)
|
||||||
|
if cmp.is_visible() then
|
||||||
|
return cmp.select_prev()
|
||||||
|
end
|
||||||
|
|
||||||
|
if cmp.snippet_active() then
|
||||||
|
return cmp.snippet_backward()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
"fallback",
|
||||||
|
},
|
||||||
|
["<CR>"] = { "accept", "fallback" },
|
||||||
|
["Up"] = {},
|
||||||
|
["Down"] = {},
|
||||||
|
},
|
||||||
|
|
||||||
|
appearance = {
|
||||||
|
nerd_font_variant = "mono",
|
||||||
|
},
|
||||||
|
|
||||||
|
cmdline = {
|
||||||
|
completion = {
|
||||||
|
menu = { auto_show = true },
|
||||||
|
list = { selection = { preselect = false } },
|
||||||
|
},
|
||||||
|
|
||||||
|
keymap = {
|
||||||
|
["<Tab>"] = {
|
||||||
|
function(cmp)
|
||||||
|
if cmp.is_visible() then
|
||||||
|
return cmp.select_next()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
"fallback",
|
||||||
|
},
|
||||||
|
["<S-Tab>"] = {
|
||||||
|
function(cmp)
|
||||||
|
if cmp.is_visible() then
|
||||||
|
return cmp.select_prev()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
"fallback",
|
||||||
|
},
|
||||||
|
["<CR>"] = { "accept", "fallback" },
|
||||||
|
["Up"] = {},
|
||||||
|
["Down"] = {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
completion = {
|
||||||
|
documentation = { auto_show = true, auto_show_delay_ms = 50 },
|
||||||
|
keyword = { range = "full" },
|
||||||
|
accept = { auto_brackets = { enabled = true } },
|
||||||
|
ghost_text = { enabled = true },
|
||||||
|
list = {
|
||||||
|
selection = {
|
||||||
|
-- preselect = false,
|
||||||
|
auto_insert = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
menu = {
|
||||||
|
scrollbar = false,
|
||||||
|
border = "single",
|
||||||
|
draw = {
|
||||||
|
padding = 1,
|
||||||
|
columns = {
|
||||||
|
{ "kind_icon" },
|
||||||
|
{ "label", "label_description", gap = 1 },
|
||||||
|
{ "kind" },
|
||||||
|
},
|
||||||
|
components = M.components,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
signature = { enabled = true },
|
||||||
|
|
||||||
|
sources = {
|
||||||
|
default = { "lsp", "path", "snippets", "buffer", "copilot" },
|
||||||
|
providers = {
|
||||||
|
lsp = {
|
||||||
|
score_offset = 50,
|
||||||
|
},
|
||||||
|
|
||||||
|
path = {
|
||||||
|
opts = {
|
||||||
|
get_cwd = function()
|
||||||
|
return vim.fn.getcwd()
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
buffer = {
|
||||||
|
score_offset = -10,
|
||||||
|
},
|
||||||
|
|
||||||
|
snippets = {
|
||||||
|
score_offset = 0,
|
||||||
|
},
|
||||||
|
|
||||||
|
copilot = {
|
||||||
|
name = "copilot",
|
||||||
|
module = "blink-copilot",
|
||||||
|
score_offset = 100,
|
||||||
|
async = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
snippets = {
|
||||||
|
preset = "default",
|
||||||
|
},
|
||||||
|
|
||||||
|
fuzzy = { implementation = "prefer_rust_with_warning" },
|
||||||
|
},
|
||||||
|
opts_extend = { "sources.default" },
|
||||||
|
}
|
||||||
|
|
||||||
|
return opts
|
||||||
@@ -20,7 +20,7 @@ require("copilot").setup({
|
|||||||
hide_during_completion = true,
|
hide_during_completion = true,
|
||||||
debounce = 75,
|
debounce = 75,
|
||||||
keymap = {
|
keymap = {
|
||||||
accept = "<A-tab>",
|
accept = "<A-a>",
|
||||||
accept_word = false,
|
accept_word = false,
|
||||||
accept_line = false,
|
accept_line = false,
|
||||||
next = "<M-]>",
|
next = "<M-]>",
|
||||||
|
|||||||
+98
-112
@@ -1,43 +1,28 @@
|
|||||||
local cmp = require("cmp")
|
local function flatten_to_array(t)
|
||||||
local cmp_lsp = require("cmp_nvim_lsp")
|
local res = {}
|
||||||
|
local function _flatten(tbl)
|
||||||
|
for _, v in ipairs(tbl) do
|
||||||
|
if type(v) == "table" then
|
||||||
|
_flatten(v)
|
||||||
|
else
|
||||||
|
table.insert(res, v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
_flatten(t)
|
||||||
|
return res
|
||||||
|
end
|
||||||
|
|
||||||
local capabilities = vim.tbl_deep_extend(
|
local capabilities = vim.tbl_deep_extend(
|
||||||
"force",
|
"force",
|
||||||
{},
|
{},
|
||||||
vim.lsp.protocol.make_client_capabilities(),
|
vim.lsp.protocol.make_client_capabilities(),
|
||||||
cmp_lsp.default_capabilities()
|
require("blink.cmp").get_lsp_capabilities()
|
||||||
)
|
)
|
||||||
|
|
||||||
local cmp_kinds = {
|
require("fidget").setup {}
|
||||||
Text = ' ',
|
|
||||||
Method = ' ',
|
|
||||||
Function = ' ',
|
|
||||||
Constructor = ' ',
|
|
||||||
Field = ' ',
|
|
||||||
Variable = ' ',
|
|
||||||
Class = ' ',
|
|
||||||
Interface = ' ',
|
|
||||||
Module = ' ',
|
|
||||||
Property = ' ',
|
|
||||||
Unit = ' ',
|
|
||||||
Value = ' ',
|
|
||||||
Enum = ' ',
|
|
||||||
Keyword = ' ',
|
|
||||||
Snippet = ' ',
|
|
||||||
Color = ' ',
|
|
||||||
File = ' ',
|
|
||||||
Reference = ' ',
|
|
||||||
Folder = ' ',
|
|
||||||
EnumMember = ' ',
|
|
||||||
Constant = ' ',
|
|
||||||
Struct = ' ',
|
|
||||||
Event = ' ',
|
|
||||||
Operator = ' ',
|
|
||||||
TypeParameter = ' ',
|
|
||||||
}
|
|
||||||
|
|
||||||
require("fidget").setup({})
|
|
||||||
require("mason").setup()
|
require("mason").setup()
|
||||||
require("mason-lspconfig").setup({
|
require("mason-lspconfig").setup {
|
||||||
automatic_enable = true,
|
automatic_enable = true,
|
||||||
ensure_installed = {
|
ensure_installed = {
|
||||||
"lua_ls",
|
"lua_ls",
|
||||||
@@ -52,24 +37,28 @@ require("mason-lspconfig").setup({
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
["tailwindcss"] = function()
|
["tailwindcss"] = function()
|
||||||
local lspconfig = require("lspconfig")
|
local lspconfig = require "lspconfig"
|
||||||
lspconfig.tailwindcss.setup {
|
lspconfig.tailwindcss.setup {
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
|
|
||||||
["css-lsp"] = function()
|
["css-lsp"] = function()
|
||||||
local lspconfig = require("lspconfig")
|
local lspconfig = require "lspconfig"
|
||||||
lspconfig.cssls.setup {
|
lspconfig.cssls.setup {
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
|
|
||||||
zls = function()
|
zls = function()
|
||||||
local lspconfig = require("lspconfig")
|
local lspconfig = require "lspconfig"
|
||||||
lspconfig.zls.setup({
|
lspconfig.zls.setup {
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
root_dir = lspconfig.util.root_pattern(".git", "build.zig", "zls.json"),
|
root_dir = lspconfig.util.root_pattern(
|
||||||
|
".git",
|
||||||
|
"build.zig",
|
||||||
|
"zls.json"
|
||||||
|
),
|
||||||
settings = {
|
settings = {
|
||||||
zls = {
|
zls = {
|
||||||
enable_inlay_hints = true,
|
enable_inlay_hints = true,
|
||||||
@@ -77,89 +66,35 @@ require("mason-lspconfig").setup({
|
|||||||
warn_style = true,
|
warn_style = true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
vim.g.zig_fmt_parse_errors = 0
|
vim.g.zig_fmt_parse_errors = 0
|
||||||
vim.g.zig_fmt_autosave = 0
|
vim.g.zig_fmt_autosave = 0
|
||||||
|
|
||||||
end,
|
end,
|
||||||
["lua_ls"] = function()
|
["lua_ls"] = function()
|
||||||
local lspconfig = require("lspconfig")
|
local lspconfig = require "lspconfig"
|
||||||
lspconfig.lua_ls.setup {
|
lspconfig.lua_ls.setup {
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
settings = {
|
settings = {
|
||||||
Lua = {
|
Lua = {
|
||||||
runtime = { version = "Lua 5.1" },
|
runtime = { version = "Lua 5.1" },
|
||||||
diagnostics = {
|
diagnostics = {
|
||||||
globals = { "bit", "vim", "it", "describe", "before_each", "after_each" },
|
globals = {
|
||||||
}
|
"bit",
|
||||||
}
|
"vim",
|
||||||
}
|
"it",
|
||||||
|
"describe",
|
||||||
|
"before_each",
|
||||||
|
"after_each",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
cmp.setup {
|
|
||||||
preselect = 'None',
|
|
||||||
formatting = {
|
|
||||||
fields = { 'kind', 'abbr' },
|
|
||||||
format = function(entry, vim_item)
|
|
||||||
vim_item.kind = cmp_kinds[vim_item.kind] or ''
|
|
||||||
if entry.completion_item.detail then
|
|
||||||
vim_item.menu = entry.completion_item.detail
|
|
||||||
end
|
|
||||||
return vim_item
|
|
||||||
end,
|
|
||||||
},
|
},
|
||||||
completion = { completeopt = "menu,menuone" },
|
|
||||||
snippet = {
|
|
||||||
expand = function(args)
|
|
||||||
require("luasnip").lsp_expand(args.body)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
|
|
||||||
mapping = {
|
|
||||||
["<C-p>"] = cmp.mapping.select_prev_item(),
|
|
||||||
["<C-n>"] = cmp.mapping.select_next_item(),
|
|
||||||
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
|
||||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
|
||||||
["<C-Space>"] = cmp.mapping.complete(),
|
|
||||||
["<C-e>"] = cmp.mapping.close(),
|
|
||||||
["<CR>"] = cmp.mapping.confirm {
|
|
||||||
behavior = cmp.ConfirmBehavior.Insert,
|
|
||||||
select = true,
|
|
||||||
},
|
|
||||||
["<Tab>"] = cmp.mapping(function(fallback)
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_next_item()
|
|
||||||
elseif require("luasnip").expand_or_jumpable() then
|
|
||||||
require("luasnip").expand_or_jump()
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { "i", "s" }),
|
|
||||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_prev_item()
|
|
||||||
elseif require("luasnip").jumpable(-1) then
|
|
||||||
require("luasnip").jump(-1)
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { "i", "s" }),
|
|
||||||
},
|
|
||||||
|
|
||||||
sources = cmp.config.sources({
|
|
||||||
{ name = "path" },
|
|
||||||
{ name = "nvim_lsp" },
|
|
||||||
{ name = "luasnip" },
|
|
||||||
{ name = "buffer" },
|
|
||||||
{ name = "nvim_lua" },
|
|
||||||
}),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vim.diagnostic.config({
|
vim.diagnostic.config {
|
||||||
-- update_in_insert = true,
|
|
||||||
virtual_text = false,
|
virtual_text = false,
|
||||||
virtual_lines = false,
|
virtual_lines = false,
|
||||||
signs = true,
|
signs = true,
|
||||||
@@ -172,20 +107,32 @@ vim.diagnostic.config({
|
|||||||
header = "",
|
header = "",
|
||||||
prefix = "",
|
prefix = "",
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
|
|
||||||
local lspconfig = vim.lsp.config
|
local lspconfig = vim.lsp.config
|
||||||
|
|
||||||
lspconfig("texlab", {
|
lspconfig("texlab", {
|
||||||
cmd = { "texlab" },
|
cmd = { "texlab" },
|
||||||
filetypes = { "tex", "bib", "plaintex" },
|
filetypes = { "tex", "bib", "plaintex" },
|
||||||
root_markers = { ".git", ".latexmkrc", "latexmkrc", ".texlabroot", "texlabroot", "Tectonic.toml" },
|
root_markers = {
|
||||||
|
".git",
|
||||||
|
".latexmkrc",
|
||||||
|
"latexmkrc",
|
||||||
|
".texlabroot",
|
||||||
|
"texlabroot",
|
||||||
|
"Tectonic.toml",
|
||||||
|
},
|
||||||
settings = {
|
settings = {
|
||||||
texlab = {
|
texlab = {
|
||||||
rootDirectory = nil,
|
rootDirectory = nil,
|
||||||
build = {
|
build = {
|
||||||
executable = "latexmk",
|
executable = "latexmk",
|
||||||
args = { "-pdf", "-interaction=nonstopmode", "-synctex=1", "%f" },
|
args = {
|
||||||
|
"-pdf",
|
||||||
|
"-interaction=nonstopmode",
|
||||||
|
"-synctex=1",
|
||||||
|
"%f",
|
||||||
|
},
|
||||||
onSave = true,
|
onSave = true,
|
||||||
forwardSearchAfter = true,
|
forwardSearchAfter = true,
|
||||||
},
|
},
|
||||||
@@ -193,7 +140,8 @@ lspconfig("texlab", {
|
|||||||
executable = "zathura",
|
executable = "zathura",
|
||||||
args = {
|
args = {
|
||||||
"--synctex-editor-command",
|
"--synctex-editor-command",
|
||||||
[[ nvim-texlabconfig -file '%%%{input}' -line %%%{line} -server ]] .. vim.v.servername,
|
[[ nvim-texlabconfig -file '%%%{input}' -line %%%{line} -server ]]
|
||||||
|
.. vim.v.servername,
|
||||||
"--synctex-forward",
|
"--synctex-forward",
|
||||||
"%l:1:%f",
|
"%l:1:%f",
|
||||||
"%p",
|
"%p",
|
||||||
@@ -206,7 +154,7 @@ lspconfig("texlab", {
|
|||||||
diagnosticsDelay = 300,
|
diagnosticsDelay = 300,
|
||||||
latexFormatter = "latexindent",
|
latexFormatter = "latexindent",
|
||||||
latexindent = {
|
latexindent = {
|
||||||
['local'] = nil,
|
["local"] = nil,
|
||||||
modifyLineBreaks = false,
|
modifyLineBreaks = false,
|
||||||
},
|
},
|
||||||
bibtexFormatter = "texlab",
|
bibtexFormatter = "texlab",
|
||||||
@@ -219,6 +167,27 @@ lspconfig("qmlls", {
|
|||||||
cmd = { "qmlls6" },
|
cmd = { "qmlls6" },
|
||||||
})
|
})
|
||||||
|
|
||||||
|
lspconfig("jsonls", {
|
||||||
|
settings = {
|
||||||
|
json = {
|
||||||
|
schemas = require("schemastore").json.schemas(),
|
||||||
|
validate = { enable = true },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
lspconfig("yamlls", {
|
||||||
|
settings = {
|
||||||
|
yaml = {
|
||||||
|
schemaStore = {
|
||||||
|
enable = false,
|
||||||
|
url = "",
|
||||||
|
},
|
||||||
|
schemas = require("schemastore").yaml.schemas(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
local lspenable = vim.lsp.enable
|
local lspenable = vim.lsp.enable
|
||||||
local servers = {
|
local servers = {
|
||||||
"html",
|
"html",
|
||||||
@@ -229,8 +198,25 @@ local servers = {
|
|||||||
"sourcekit",
|
"sourcekit",
|
||||||
"qmlls",
|
"qmlls",
|
||||||
"tailwindcss",
|
"tailwindcss",
|
||||||
|
"systemd-lsp",
|
||||||
|
require("mason-lspconfig").get_installed_servers(),
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, server in ipairs(servers) do
|
local flat_servers = flatten_to_array(servers)
|
||||||
|
|
||||||
|
for _, server in ipairs(flat_servers) do
|
||||||
|
lspconfig(server, {
|
||||||
|
on_attach = function(client, bufnr)
|
||||||
|
if client.name == "typos_lsp" or client.name == "copilot" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
require("workspace-diagnostics").populate_workspace_diagnostics(
|
||||||
|
client,
|
||||||
|
bufnr
|
||||||
|
)
|
||||||
|
end,
|
||||||
|
capabilities = capabilities,
|
||||||
|
})
|
||||||
lspenable(server)
|
lspenable(server)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,9 +2,7 @@ local M = {}
|
|||||||
|
|
||||||
M.plugin = {
|
M.plugin = {
|
||||||
"sbdchd/neoformat",
|
"sbdchd/neoformat",
|
||||||
event = { "BufReadPre", "BufNewFile" },
|
|
||||||
config = function()
|
config = function()
|
||||||
-- === formatter enablement (order = priority) ===
|
|
||||||
vim.g.neoformat_enabled_lua = { "stylua" }
|
vim.g.neoformat_enabled_lua = { "stylua" }
|
||||||
vim.g.neoformat_enabled_python = { "black" }
|
vim.g.neoformat_enabled_python = { "black" }
|
||||||
vim.g.neoformat_enabled_javascript = { "prettier" }
|
vim.g.neoformat_enabled_javascript = { "prettier" }
|
||||||
@@ -15,223 +13,6 @@ M.plugin = {
|
|||||||
vim.g.neoformat_enabled_bash = { "shfmt" }
|
vim.g.neoformat_enabled_bash = { "shfmt" }
|
||||||
vim.g.neoformat_enabled_zsh = { "shfmt" }
|
vim.g.neoformat_enabled_zsh = { "shfmt" }
|
||||||
vim.g.neoformat_enabled_powershell = { "pwshfmt" } -- experimental
|
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,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
local prettier = require("prettier")
|
||||||
|
|
||||||
|
prettier.setup({
|
||||||
|
bin = 'prettier',
|
||||||
|
filetypes = {
|
||||||
|
"css",
|
||||||
|
"graphql",
|
||||||
|
"html",
|
||||||
|
"javascript",
|
||||||
|
"javascriptreact",
|
||||||
|
"json",
|
||||||
|
"less",
|
||||||
|
"markdown",
|
||||||
|
"scss",
|
||||||
|
"typescript",
|
||||||
|
"typescriptreact",
|
||||||
|
"yaml",
|
||||||
|
},
|
||||||
|
})
|
||||||
@@ -63,3 +63,13 @@ map("n", "<C-q>", function() Snacks.terminal.toggle() end, { desc = "Toggle Term
|
|||||||
|
|
||||||
-- Gitbrowse
|
-- Gitbrowse
|
||||||
map("n", "<leader>gb", function() Snacks.gitbrowse.open() end )
|
map("n", "<leader>gb", function() Snacks.gitbrowse.open() end )
|
||||||
|
|
||||||
|
-- Notif history
|
||||||
|
map("n", "<leader>n", function()
|
||||||
|
Snacks.notifier.show_history()
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Actions Previewer
|
||||||
|
map({ "n", "v" }, "<leader>ap", require("actions-preview").code_actions)
|
||||||
|
|
||||||
|
map("n", "K", require("pretty_hover").hover)
|
||||||
|
|||||||
+10
-1
@@ -102,7 +102,6 @@ return {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"zbirenbaum/copilot.lua",
|
"zbirenbaum/copilot.lua",
|
||||||
lazy = true,
|
|
||||||
cmd = "Copilot",
|
cmd = "Copilot",
|
||||||
event = "InsertEnter",
|
event = "InsertEnter",
|
||||||
config = function()
|
config = function()
|
||||||
@@ -161,6 +160,8 @@ return {
|
|||||||
"L3MON4D3/LuaSnip",
|
"L3MON4D3/LuaSnip",
|
||||||
"saadparwaiz1/cmp_luasnip",
|
"saadparwaiz1/cmp_luasnip",
|
||||||
"j-hui/fidget.nvim",
|
"j-hui/fidget.nvim",
|
||||||
|
"b0o/schemastore.nvim",
|
||||||
|
"saghen/blink.cmp",
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
require("config.lspconfig")
|
require("config.lspconfig")
|
||||||
@@ -269,4 +270,12 @@ return {
|
|||||||
require("config.zterm-navigator")
|
require("config.zterm-navigator")
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"Fildo7525/pretty_hover",
|
||||||
|
event = "LspAttach",
|
||||||
|
opts = {},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"artemave/workspace-diagnostics.nvim",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ $packages = @(
|
|||||||
"Ninja-build.Ninja"
|
"Ninja-build.Ninja"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# cargo install --locked tree-sitter-cli
|
||||||
|
|
||||||
foreach ( $package in $packages ) {
|
foreach ( $package in $packages ) {
|
||||||
Write-Host "Installing $package..." -foregroundcolor yellow
|
Write-Host "Installing $package..." -foregroundcolor yellow
|
||||||
# winget install $package
|
# winget install $package
|
||||||
@@ -18,7 +20,7 @@ foreach ( $package in $packages ) {
|
|||||||
|
|
||||||
$list = @(
|
$list = @(
|
||||||
"Git.Git",
|
"Git.Git",
|
||||||
"ajeetdsouza.zoxide",
|
"ajeetdsouza.zoxide"
|
||||||
)
|
)
|
||||||
|
|
||||||
Write-Host "Module list" -ForegroundColor Magenta
|
Write-Host "Module list" -ForegroundColor Magenta
|
||||||
|
|||||||
Reference in New Issue
Block a user