config.nvim/lua/set.lua
2026-05-12 14:28:39 +02:00

85 lines
2.1 KiB
Lua

vim.opt.shadafile = "NONE"
vim.opt.nu = true
vim.opt.rnu = true
vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true
vim.opt.smartindent = true
vim.opt.wrap = false
vim.opt.list = true
vim.opt.laststatus = 3
vim.opt.swapfile = false
vim.opt.backup = false
vim.opt.undofile = true
vim.opt.hlsearch = true
vim.opt.incsearch = true
vim.opt.ignorecase = true
vim.opt.smartcase = true
vim.opt.termguicolors = true
vim.opt.scrolloff = 10
vim.opt.signcolumn = "yes"
vim.opt.updatetime = 50
-- use system clipboard
vim.opt.clipboard = "unnamedplus"
vim.g.clipboard = {
name = "win32yank-wsl",
copy = {
["+"] = "win32yank.exe -i --crlf",
["*"] = "win32yank.exe -i --crlf"
},
paste = {
["+"] = "win32yank.exe -o --crlf",
["*"] = "win32yank.exe -o --crlf"
},
cache_enable = 0,
}
local function fzf_open_terminal()
local tmp = vim.fn.tempname()
local cwd = vim.fn.getcwd()
local rg = [[rg --files --hidden --glob "!.git/**" --glob "!node_modules/**" --glob "!.angular/**"]]
local awk = [[awk -F'/' '{dir = (NF>1 ? substr($0, 1, length($0)-length($NF)-1) : "."); printf("%s [%s]\t%s\n", $NF, dir, $0)}']]
local inner = string.format("cd %s && %s | %s | fzf --height 40%% > %s",
vim.fn.shellescape(cwd), rg, awk, vim.fn.shellescape(tmp))
vim.cmd('belowright split')
local bufnr = vim.api.nvim_create_buf(false, true)
vim.api.nvim_win_set_buf(0, bufnr)
-- pass argv form to avoid fish parsing issues
vim.fn.termopen({'bash', '-ic', inner}, {
on_exit = function()
local lines = vim.fn.readfile(tmp)
os.remove(tmp)
if #lines == 0 then
vim.schedule(function()
if vim.api.nvim_buf_is_valid(bufnr) then vim.api.nvim_buf_delete(bufnr, {force=true}) end
end)
return
end
local sel = lines[1]:match("\t(.*)$") or lines[1]
vim.schedule(function()
if vim.api.nvim_buf_is_valid(bufnr) then vim.api.nvim_buf_delete(bufnr, {force=true}) end
vim.cmd('edit ' .. vim.fn.fnameescape(sel))
end)
end,
})
vim.cmd('startinsert')
end
vim.keymap.set('n', '<leader>o', fzf_open_terminal, {noremap=true, silent=true})