update bashrc.arch and nvim
This commit is contained in:
parent
63daba3b4a
commit
78115fb3e0
7 changed files with 94 additions and 135 deletions
|
|
@ -234,5 +234,5 @@ ed() {
|
|||
}
|
||||
|
||||
export GOPATH=$HOME/go
|
||||
export PATH=$PATH:$GOPATH:$GOPATH/bin
|
||||
export PATH=$PATH:$GOPATH:$GOPATH/bin:/usr/local/go/bin
|
||||
export EDITOR=nvim
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@
|
|||
"todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" },
|
||||
"tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" },
|
||||
"undotree": { "branch": "master", "commit": "28f2f54a34baff90ea6f4a735ef1813ad875c743" },
|
||||
"vim-closetag": { "branch": "master", "commit": "d0a562f8bdb107a50595aefe53b1a690460c3822" },
|
||||
"vim-floaterm": { "branch": "master", "commit": "fd4bdd66eca56c6cc59f2119e4447496d8cde2ea" },
|
||||
"which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,17 +2,29 @@ local Utils = require("juancwu.utils")
|
|||
|
||||
if Utils.os.is_linux() then
|
||||
local wayland_display = os.getenv("WAYLAND_DISPLAY")
|
||||
local clipboard_cmd = "xclip"
|
||||
if wayland_display then
|
||||
if Utils.os.is_wsl() then
|
||||
vim.g.clipboard = {
|
||||
name = "win32yank",
|
||||
copy = {
|
||||
["+"] = "win32yank.exe -i --crlf",
|
||||
["*"] = "win32yank.exe -i --crlf",
|
||||
},
|
||||
paste = {
|
||||
["+"] = "win32yank.exe -o --lf",
|
||||
["*"] = "win32yank.exe -o --lf",
|
||||
},
|
||||
cache_enabled = 0,
|
||||
}
|
||||
elseif wayland_display then
|
||||
vim.g.clipboard = {
|
||||
name = "wl-clipboard",
|
||||
copy = {
|
||||
['+'] = "wl-copy",
|
||||
['*'] = "wl-copy",
|
||||
["+"] = "wl-copy",
|
||||
["*"] = "wl-copy",
|
||||
},
|
||||
paste = {
|
||||
['+'] = "wl-paste",
|
||||
['*'] = "wl-paste",
|
||||
["+"] = "wl-paste",
|
||||
["*"] = "wl-paste",
|
||||
},
|
||||
cache_enabled = 1,
|
||||
}
|
||||
|
|
@ -20,12 +32,12 @@ if Utils.os.is_linux() then
|
|||
vim.g.clipboard = {
|
||||
name = "xclip",
|
||||
copy = {
|
||||
['+'] = "xclip -sel clip -i -quiet",
|
||||
['*'] = "xclip -sel primary -i -quiet",
|
||||
["+"] = "xclip -sel clip -i -quiet",
|
||||
["*"] = "xclip -sel primary -i -quiet",
|
||||
},
|
||||
paste = {
|
||||
['+'] = "xclip -sel clip -o -quiet",
|
||||
['*'] = "xclip -sel primary -o -quiet",
|
||||
["+"] = "xclip -sel clip -o -quiet",
|
||||
["*"] = "xclip -sel primary -o -quiet",
|
||||
},
|
||||
cache_enabled = 1,
|
||||
}
|
||||
|
|
@ -34,26 +46,13 @@ elseif Utils.os.is_mac() then
|
|||
vim.g.clipboard = {
|
||||
name = "mac-clipboard",
|
||||
copy = {
|
||||
['+'] = "pbcopy",
|
||||
['*'] = "pbcopy",
|
||||
["+"] = "pbcopy",
|
||||
["*"] = "pbcopy",
|
||||
},
|
||||
paste = {
|
||||
['+'] = "pbpaste",
|
||||
['*'] = "pbpaste",
|
||||
["+"] = "pbpaste",
|
||||
["*"] = "pbpaste",
|
||||
},
|
||||
cache_enabled = 1,
|
||||
}
|
||||
elseif Utils.os.is_wsl() then
|
||||
vim.g.clipboard = {
|
||||
name = "win32yank",
|
||||
copy = {
|
||||
['+'] = "win32yank.exe -i --crlf",
|
||||
['*'] = "win32yank.exe -i --crlf",
|
||||
},
|
||||
paste = {
|
||||
['+'] = "win32yank.exe -o --lf",
|
||||
['*'] = "win32yank.exe -o --lf",
|
||||
},
|
||||
cache_enabled = 0,
|
||||
}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,8 +2,23 @@ return {
|
|||
"windwp/nvim-ts-autotag",
|
||||
dependencies = { "nvim-treesitter/nvim-treesitter", build = ':TSUpdate' },
|
||||
ft = {
|
||||
'html',
|
||||
'javascript',
|
||||
'typescript',
|
||||
'javascriptreact',
|
||||
'typescriptreact',
|
||||
'svelte',
|
||||
'vue',
|
||||
'tsx',
|
||||
'jsx',
|
||||
'xml',
|
||||
'php',
|
||||
'markdown',
|
||||
'astro',
|
||||
'glimmer',
|
||||
'handlebars',
|
||||
'hbs',
|
||||
'templ',
|
||||
},
|
||||
config = function()
|
||||
local autotag = require('nvim-ts-autotag')
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
return {
|
||||
"alvan/vim-closetag"
|
||||
}
|
||||
|
|
@ -1,74 +1,21 @@
|
|||
local formatters_by_ft = {
|
||||
lua = { "stylua" },
|
||||
javascript = { "prettier", "biome" },
|
||||
typescript = { "prettier", "biome" },
|
||||
javascriptreact = { "prettier", "biome" },
|
||||
typescriptreact = { "prettier", "biome" },
|
||||
css = { "prettier", "biome" },
|
||||
markdown = { "prettier", "biome" },
|
||||
jsonc = { "prettier", "biome" },
|
||||
json = { "prettier", "biome" },
|
||||
go = { "gofmt" },
|
||||
javascript = { "biome" },
|
||||
typescript = { "biome" },
|
||||
javascriptreact = { "biome" },
|
||||
typescriptreact = { "biome" },
|
||||
css = { "biome" },
|
||||
markdown = { "biome" },
|
||||
jsonc = { "biome" },
|
||||
json = { "biome" },
|
||||
go = { "gofmt", "goimports" },
|
||||
python = { "autopep8" },
|
||||
yaml = { "yamlfmt" },
|
||||
yml = { "yamlfmt" },
|
||||
zig = { "zigfmt" },
|
||||
rust = { "rustfmt" },
|
||||
}
|
||||
|
||||
-- Function to find the first config file by walking up the directory tree
|
||||
local function find_first_config()
|
||||
local current_dir = vim.fn.expand("%:p:h")
|
||||
local home_dir = vim.fn.expand("$HOME")
|
||||
|
||||
local config_files = {
|
||||
prettier = { ".prettierrc", ".prettierrc.json", ".prettierrc.js" },
|
||||
biome = { "biome.json" },
|
||||
}
|
||||
|
||||
while current_dir ~= home_dir and current_dir ~= "/" do
|
||||
for formatter, patterns in pairs(config_files) do
|
||||
for _, pattern in ipairs(patterns) do
|
||||
local config_file = current_dir .. "/" .. pattern
|
||||
if vim.fn.filereadable(config_file) == 1 then
|
||||
return formatter
|
||||
end
|
||||
end
|
||||
end
|
||||
current_dir = vim.fn.fnamemodify(current_dir, ":h")
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Function to determine the formatter based on config files and file type
|
||||
local function get_formatter()
|
||||
local filetype = vim.bo.filetype
|
||||
local available_formatters = formatters_by_ft[filetype] or {}
|
||||
local formatter = find_first_config()
|
||||
|
||||
if formatter then
|
||||
if formatter == "prettier" and vim.tbl_contains(available_formatters, "prettier") then
|
||||
vim.g.current_formatter = "prettier"
|
||||
return { "prettier" }
|
||||
elseif formatter == "biome" and vim.tbl_contains(available_formatters, "biome") then
|
||||
vim.g.current_formatter = "biome"
|
||||
return { "biome" }
|
||||
end
|
||||
end
|
||||
|
||||
-- Default to the first available formatter for the file type, or prettier if none specified
|
||||
vim.g.current_formatter = available_formatters[1] or "prettier"
|
||||
return { vim.g.current_formatter }
|
||||
end
|
||||
|
||||
local function format_on_save(bufnr)
|
||||
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
|
||||
return
|
||||
end
|
||||
local formatters = get_formatter()
|
||||
return {
|
||||
timeout_ms = 500,
|
||||
lsp_format = "fallback",
|
||||
formatters = formatters,
|
||||
}
|
||||
end
|
||||
|
||||
return {
|
||||
"stevearc/conform.nvim",
|
||||
event = { "BufWritePre", "BufEnter" },
|
||||
|
|
@ -77,8 +24,7 @@ return {
|
|||
{
|
||||
"<leader>ff",
|
||||
function()
|
||||
local formatters = get_formatter()
|
||||
require("conform").format({ async = true, lsp_format = "fallback", formatters = formatters })
|
||||
require("conform").format({ async = true, lsp_format = "fallback" })
|
||||
end,
|
||||
mode = "",
|
||||
desc = "[F]ormat buffer",
|
||||
|
|
@ -88,7 +34,15 @@ return {
|
|||
require("conform").setup({
|
||||
notify_on_error = false,
|
||||
formatters_by_ft = formatters_by_ft,
|
||||
format_on_save = format_on_save,
|
||||
format_on_save = function(bufnr)
|
||||
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
|
||||
return
|
||||
end
|
||||
return {
|
||||
timeout_ms = 500,
|
||||
lsp_format = "fallback",
|
||||
}
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_user_command("FormatDisable", function()
|
||||
|
|
@ -102,11 +56,6 @@ return {
|
|||
end, {
|
||||
desc = "Enable autoformat on save",
|
||||
})
|
||||
|
||||
vim.api.nvim_create_user_command("Formatter", function()
|
||||
print("Current formatter: " .. (vim.g.current_formatter or "none"))
|
||||
end, {
|
||||
desc = "Show current formatter being used",
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ return {
|
|||
}
|
||||
|
||||
local ensure_installed = vim.tbl_keys(servers or {})
|
||||
vim.list_extend(ensure_installed, { "stylua", "yamlfmt", "autopep8", "biome" })
|
||||
vim.list_extend(ensure_installed, { "stylua", "yamlfmt", "autopep8", "biome", "goimports" })
|
||||
require("mason-tool-installer").setup({ ensure_installed = ensure_installed })
|
||||
|
||||
require("mason-lspconfig").setup({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue