Public Access
68 lines
2.0 KiB
Lua
68 lines
2.0 KiB
Lua
vim.cmd("set tabstop=4")
|
|
vim.cmd("set shiftwidth=4")
|
|
vim.wo.relativenumber = true
|
|
vim.opt.number = true
|
|
vim.g.mapleader = " "
|
|
|
|
-- Enable line wrapping
|
|
vim.opt.wrap = true
|
|
vim.opt.linebreak = true
|
|
vim.opt.showbreak = "↪ "
|
|
|
|
-- Make 'j' and 'k' navigate visual lines (not logical lines)
|
|
vim.keymap.set("n", "j", "gj", { noremap = true, silent = true })
|
|
vim.keymap.set("n", "k", "gk", { noremap = true, silent = true })
|
|
vim.keymap.set("v", "j", "gj", { noremap = true, silent = true })
|
|
vim.keymap.set("v", "k", "gk", { noremap = true, silent = true })
|
|
|
|
-- Spellchecker
|
|
vim.api.nvim_create_autocmd("FileType", {
|
|
callback = function()
|
|
local buftype = vim.api.nvim_buf_get_option(0, "buftype")
|
|
local filetype = vim.api.nvim_buf_get_option(0, "filetype")
|
|
|
|
local skip_buftypes = { "nofile", "prompt", "terminal" }
|
|
local skip_filetypes = { "cmp_menu", "cmp_doc", "TelescopePrompt", "NvimTree" }
|
|
|
|
-- If current buffer is in skip list, do nothing
|
|
for _, bt in ipairs(skip_buftypes) do
|
|
if buftype == bt then
|
|
return
|
|
end
|
|
end
|
|
for _, ft in ipairs(skip_filetypes) do
|
|
if filetype == ft then
|
|
return
|
|
end
|
|
end
|
|
|
|
-- Else, enable spellcheck
|
|
vim.opt_local.spell = true
|
|
vim.opt_local.spelllang = "en"
|
|
end,
|
|
})
|
|
|
|
-- Toggle spell check with <leader>sc
|
|
vim.keymap.set("n", "<leader>sc", function()
|
|
vim.wo.spell = not vim.wo.spell
|
|
print("Spell checking: " .. (vim.wo.spell and "ON" or "OFF"))
|
|
end, { desc = "Toggle spell checking" })
|
|
|
|
-- Switch between English and German with <leader>sl
|
|
vim.keymap.set("n", "<leader>sl", function()
|
|
local current = vim.opt.spelllang:get()[1] or ""
|
|
local new_lang = current == "en" and "de" or "en"
|
|
vim.opt.spelllang = new_lang
|
|
print("Spell language: " .. new_lang)
|
|
end, { desc = "Switch spell language" })
|
|
|
|
-- Clear search highlights when entering insert mode.
|
|
vim.api.nvim_create_autocmd("InsertEnter", {
|
|
callback = function()
|
|
-- Delay the nohlsearch slightly to ensure it takes effect
|
|
vim.defer_fn(function()
|
|
vim.cmd("nohlsearch")
|
|
end, 10)
|
|
end,
|
|
})
|