initial commit
This commit is contained in:
commit
8eb7f9c5fb
8 changed files with 1261 additions and 0 deletions
156
neovim/plugins.lua
Normal file
156
neovim/plugins.lua
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
local hostname = "maia"
|
||||
|
||||
local servers = {
|
||||
clangd = {},
|
||||
textlab = {},
|
||||
lua_ls = {
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
version = "LuaJIT",
|
||||
},
|
||||
diagnostics = {
|
||||
globals = { "vim" },
|
||||
},
|
||||
workspace = {
|
||||
library = vim.api.nvim_get_runtime_file("", true),
|
||||
checkThirdParty = false,
|
||||
},
|
||||
telemetry = {
|
||||
enable = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
nixd = {
|
||||
nixpkgs = {
|
||||
expr = 'import (builtins.getFlake "/etc/nixos").inputs.nixpkgs {}',
|
||||
},
|
||||
formatting = { command = { "nixfmt" } },
|
||||
options = {
|
||||
nixos = {
|
||||
expr = '(builtins.getFlake "/etc/nixos").nixosConfigurations.' .. hostname .. ".options",
|
||||
},
|
||||
home_manager = {
|
||||
expr = '(builtins.getFlake "/etc/nixos").homeConfigurations.' .. hostname .. ".options",
|
||||
},
|
||||
},
|
||||
},
|
||||
phpactor = {},
|
||||
zls = {
|
||||
settings = {
|
||||
zls = {
|
||||
enable_build_on_save = true,
|
||||
semantic_tokens = "partial",
|
||||
global_cache_path = vim.fn.getcwd(0, 0) .. "/.cache/zls",
|
||||
},
|
||||
},
|
||||
},
|
||||
css = {},
|
||||
scss = {},
|
||||
less = {},
|
||||
blade = {},
|
||||
html = { filetypes = { "html", "blade" } },
|
||||
htmx = { filetypes = { "html", "blade" } },
|
||||
gopls = {},
|
||||
ols = {
|
||||
enable_semantic_tokens = true,
|
||||
enable_auto_import = true,
|
||||
checker_args = "-vet",
|
||||
},
|
||||
wgsl_analyzer = {},
|
||||
}
|
||||
for server, config in pairs(servers) do
|
||||
vim.lsp.config(server, config)
|
||||
vim.lsp.enable(server)
|
||||
end
|
||||
|
||||
-- vim.api.nvim_create_autocmd("LspAttach", {
|
||||
-- group = vim.api.nvim_create_augroup("UserConfigLsp", {}),
|
||||
-- callback = function(ev)
|
||||
vim.keymap.set("n", "gn", vim.lsp.buf.declaration, { desc = "go to declaration" })
|
||||
vim.keymap.set("n", "ge", vim.lsp.buf.definition, { desc = "go to definition" })
|
||||
-- vim.keymap.set("n", "gi", vim.lsp.buf.implementaion, { desc = "go to implementation" })
|
||||
vim.keymap.set("n", "<leader>rr", vim.lsp.buf.rename, { desc = "lsp rename" })
|
||||
vim.keymap.set("n", "<leader>ra", vim.lsp.buf.code_action, { desc = "code action" })
|
||||
vim.keymap.set({ "n", "i" }, "<C-k>", vim.lsp.buf.signature_help, { desc = "signature help" })
|
||||
vim.keymap.set("n", "gr", vim.lsp.buf.references, { desc = "references" })
|
||||
-- end,
|
||||
-- })
|
||||
|
||||
local leap = require("leap")
|
||||
leap.opts.preview = function(ch0, ch1, ch2)
|
||||
return not (ch1:match("%s") or (ch0:match("%a") and ch1:match("%a") and ch2:match("%a")))
|
||||
end
|
||||
-- leap.opts.equivalence_classes = {
|
||||
-- " \t\r\n",
|
||||
-- "([{",
|
||||
-- ")]}",
|
||||
-- "'\"`",
|
||||
-- }
|
||||
vim.api.nvim_set_hl(0, "LeapBackdrop", { link = "Comment" })
|
||||
|
||||
do
|
||||
-- Return an argument table for `leap()`, tailored for f/t-motions.
|
||||
local function as_ft(key_specific_args)
|
||||
local common_args = {
|
||||
inputlen = 1,
|
||||
inclusive = true,
|
||||
-- To limit search scope to the current line:
|
||||
-- pattern = function (pat) return '\\%.l'..pat end,
|
||||
opts = {
|
||||
labels = "", -- force autojump
|
||||
safe_labels = vim.fn.mode(1):match("[no]") and "" or nil, -- [1]
|
||||
},
|
||||
}
|
||||
return vim.tbl_deep_extend("keep", common_args, key_specific_args)
|
||||
end
|
||||
|
||||
local clever = require("leap.user").with_traversal_keys -- [2]
|
||||
local clever_f = clever("f", "F")
|
||||
local clever_t = clever("t", "T")
|
||||
|
||||
for key, key_specific_args in pairs({
|
||||
f = { opts = clever_f },
|
||||
F = { backward = true, opts = clever_f },
|
||||
t = { offset = -1, opts = clever_t },
|
||||
T = { backward = true, offset = 1, opts = clever_t },
|
||||
}) do
|
||||
vim.keymap.set({ "n", "x", "o" }, key, function()
|
||||
require("leap").leap(as_ft(key_specific_args))
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("CmdlineLeave", {
|
||||
group = vim.api.nvim_create_augroup("LeapOnSearch", {}),
|
||||
callback = function()
|
||||
local ev = vim.v.event
|
||||
local is_search_cmd = (ev.cmdtype == "/") or (ev.cmdtype == "?")
|
||||
local cnt = vim.fn.searchcount().total
|
||||
if is_search_cmd and not ev.abort and (cnt > 1) then
|
||||
-- Allow CmdLineLeave-related chores to be completed before
|
||||
-- invoking Leap.
|
||||
vim.schedule(function()
|
||||
-- We want "safe" labels, but no auto-jump (as the search
|
||||
-- command already does that), so just use `safe_labels`
|
||||
-- as `labels`, with n/N removed.
|
||||
local labels = require("leap").opts.safe_labels:gsub("[nN]", "")
|
||||
-- For `pattern` search, we never need to adjust conceallevel
|
||||
-- (no user input). We cannot merge `nil` from a table, but
|
||||
-- using the option's current value has the same effect.
|
||||
local vim_opts = { ["wo.conceallevel"] = vim.wo.conceallevel }
|
||||
require("leap").leap({
|
||||
pattern = vim.fn.getreg("/"), -- last search pattern
|
||||
windows = { vim.fn.win_getid() },
|
||||
opts = { safe_labels = "", labels = labels, vim_opts = vim_opts },
|
||||
})
|
||||
end)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
vim.keymap.set({ "n", "x", "o" }, "s", "<Plug>(leap)", { desc = "leap" })
|
||||
vim.keymap.set({ "n", "x", "o" }, "S", "<Plug>(leap-from-window)", { desc = "leap across window" })
|
||||
|
||||
|
||||
145
neovim/settings.lua
Normal file
145
neovim/settings.lua
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
vim.opt.number = true
|
||||
vim.opt.relativenumber = true
|
||||
vim.opt.cursorline = true
|
||||
vim.opt.wrap = false
|
||||
vim.opt.scrolloff = 10
|
||||
vim.opt.sidescrolloff = 8
|
||||
|
||||
vim.opt.tabstop = 4
|
||||
vim.opt.shiftwidth = 4
|
||||
vim.opt.softtabstop = 4
|
||||
vim.opt.expandtab = true
|
||||
vim.opt.smartindent = true
|
||||
vim.opt.autoindent = true
|
||||
|
||||
vim.opt.ignorecase = true
|
||||
vim.opt.smartcase = true
|
||||
vim.opt.hlsearch = false
|
||||
vim.opt.incsearch = true
|
||||
|
||||
vim.opt.termguicolors = true
|
||||
vim.opt.signcolumn = "yes"
|
||||
vim.opt.colorcolumn = "120"
|
||||
vim.opt.showmatch = false
|
||||
--- vim.opt.matchtime = 2
|
||||
vim.opt.conceallevel = 0
|
||||
vim.opt.concealcursor = ""
|
||||
vim.opt.synmaxcol = 1000
|
||||
vim.opt.isfname:append("@-@")
|
||||
|
||||
vim.opt.backup = false
|
||||
vim.opt.writebackup = false
|
||||
vim.opt.swapfile = false
|
||||
vim.opt.undofile = true
|
||||
vim.opt.undodir = vim.fn.expand("~/.cache/vim/undodir")
|
||||
vim.opt.updatetime = 100
|
||||
vim.opt.timeoutlen = 500
|
||||
vim.opt.ttimeoutlen = 0
|
||||
vim.opt.autoread = true
|
||||
vim.opt.autowrite = false
|
||||
|
||||
vim.opt.hidden = true
|
||||
--- vim.opt.errorbells = false
|
||||
vim.opt.backspace = "indent,eol,start"
|
||||
vim.opt.autochdir = false
|
||||
vim.opt.path:append("**")
|
||||
vim.opt.selection = "exclusive"
|
||||
vim.opt.mouse = "a"
|
||||
vim.opt.modifiable = true
|
||||
vim.opt.encoding = "UTF-8"
|
||||
|
||||
-- Split behavior
|
||||
vim.opt.splitbelow = true
|
||||
vim.opt.splitright = true
|
||||
|
||||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = vim.api.nvim_replace_termcodes("<BS>", false, false, true)
|
||||
|
||||
vim.o.exrc = true
|
||||
vim.o.showtabline = 2
|
||||
|
||||
vim.cmd("set title")
|
||||
vim.cmd("set ic")
|
||||
|
||||
-- Delete without yanking
|
||||
vim.keymap.set({ "n", "v" }, "<localleader>d", '"_d', { desc = "Delete without yanking" })
|
||||
vim.keymap.set({ "n", "v" }, "<C-c>", '"+y', { desc = "Copy to clipboard" })
|
||||
vim.keymap.set("x", "<localleader>p", '"_dP', { desc = "Replace without yanking" })
|
||||
|
||||
-- Wayland clipboard mappings
|
||||
vim.keymap.set({ "n", "v" }, "<leader>y", '"+y', { desc = "Yank to system clipboard" })
|
||||
vim.keymap.set("n", "<leader>Y", '"+Y', { desc = "Yank line to system clipboard" })
|
||||
vim.keymap.set({ "n", "v" }, "<leader>p", '"+p', { desc = "Paste from system clipboard" })
|
||||
vim.keymap.set({ "n", "v" }, "<leader>P", '"+P', { desc = "Paste from system clipboard before cursor" })
|
||||
|
||||
-- Better J behavior
|
||||
vim.keymap.set("n", "J", "mzJ`z", { desc = "Join lines and keep cursor position" })
|
||||
|
||||
--- center when jumping
|
||||
vim.keymap.set("n", "n", "nzzzv", { desc = "Next search result (centered)" })
|
||||
vim.keymap.set("n", "N", "Nzzzv", { desc = "Previous search result (centered)" })
|
||||
vim.keymap.set("n", "<C-d>", "<C-d>zz", { desc = "Half page down (centered)" })
|
||||
vim.keymap.set("n", "<C-u>", "<C-u>zz", { desc = "Half page up (centered)" })
|
||||
|
||||
--- window navigation
|
||||
vim.keymap.set("n", "<C-w>Left", "<C-w>h", { desc = "Move to left window" })
|
||||
vim.keymap.set("n", "<C-w>Right", "<C-w>l", { desc = "Move to right window" })
|
||||
vim.keymap.set("n", "<C-w>Top", "<C-w>k", { desc = "Move to top window" })
|
||||
vim.keymap.set("n", "<C-w>Down", "<C-w>j", { desc = "Move to bottom window" })
|
||||
|
||||
vim.keymap.set("t", "<S-Esc>", "<C-\\><C-n>", { desc = "Exit terminal mode" })
|
||||
|
||||
vim.keymap.set("n", "<leader>tn", "<cmd>$tabnew<cr>", { desc = "create tab" })
|
||||
vim.keymap.set("n", "<leader>n", function()
|
||||
vim.cmd("tabnext 1")
|
||||
end, { desc = "Go to tab 1" })
|
||||
vim.keymap.set("n", "<leader>e", function()
|
||||
vim.cmd("tabnext 2")
|
||||
end, { desc = "Go to tab 2" })
|
||||
vim.keymap.set("n", "<leader>i", function()
|
||||
vim.cmd("tabnext 3")
|
||||
end, { desc = "Go to tab 3" })
|
||||
vim.keymap.set("n", "<leader>a", function()
|
||||
vim.cmd("tabnext 4")
|
||||
end, { desc = "Go to tab 4" })
|
||||
vim.keymap.set({ "n", "t" }, "<C-H>", function()
|
||||
vim.cmd("tabnext #")
|
||||
end, { desc = "Go to previous tab" })
|
||||
vim.keymap.set({ "n", "t" }, "<C-Space>", "<C-w>p", { desc = "Go to previous pane" })
|
||||
|
||||
vim.keymap.set("n", "<localleader><localleader>", "<cmd>w<cr>", { desc = "save buffer" })
|
||||
|
||||
vim.diagnostic.config({
|
||||
virtual_text = false,
|
||||
virtual_lines = true,
|
||||
signs = true,
|
||||
underline = true,
|
||||
update_in_insert = true,
|
||||
severity_sort = true,
|
||||
})
|
||||
|
||||
-- Highlight yanked text
|
||||
vim.api.nvim_create_autocmd("TextYankPost", {
|
||||
group = augroup,
|
||||
callback = function()
|
||||
vim.highlight.on_yank()
|
||||
end,
|
||||
})
|
||||
|
||||
--- return to last edit position when opening files
|
||||
vim.api.nvim_create_autocmd("BufReadPost", {
|
||||
group = augroup,
|
||||
callback = function()
|
||||
local mark = vim.api.nvim_buf_get_mark(0, '"')
|
||||
local lcount = vim.api.nvim_buf_line_count(0)
|
||||
if mark[1] > 0 and mark[1] <= lcount then
|
||||
pcall(vim.api.nvim_win_set_cursor, 0, mark)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
--- command line completion
|
||||
vim.opt.wildmenu = true
|
||||
vim.opt.wildmode = "longest:full,full"
|
||||
vim.opt.wildignore:append({ "*.o", "*.obj", "*.pyc", "*.class", "*.jar", "*.lock" })
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue