-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathoptions.lua
More file actions
53 lines (48 loc) · 1.72 KB
/
options.lua
File metadata and controls
53 lines (48 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
vim.o.autowrite = true -- save automatically at strategic points
vim.o.ignorecase = false -- case-sensitive search by default
vim.o.joinspaces = false -- no double space after . symbol
vim.o.scrolloff = 2 -- the default of 10 is obnoxious
vim.o.shiftwidth = 2 -- two spaces per shift
vim.o.smartcase = false -- no automatic case-insensitivity
vim.o.tabstop = 2 -- two spaces per tab
-- Clipboard handling
-- The scheduling is necessary because kickstart.nvim schedules
-- its own setting of the clipboard for startup performance reasons,
-- and we want our override to happen after kickstart.nvim's.
vim.schedule(function()
if vim.fn.has("linux") == 1 then
-- Sync " with PRIMARY; middle-click pastes last yank
vim.o.clipboard = "unnamed"
else
-- This platform has no PRIMARY; do not clobber clipboard
vim.opt.clipboard = ""
end
end)
-- Treesitter-based folding (upgrade from foldmethod=indent)
vim.o.foldmethod = "expr"
vim.o.foldexpr = "v:lua.vim.treesitter.foldexpr()"
vim.o.foldlevel = 99 -- start with everything open
vim.o.foldenable = true
-- Let :term terminals start in insert mode
vim.api.nvim_create_autocmd("TermOpen", {
callback = function()
vim.cmd("startinsert")
end,
})
-- Highlight trailing whitespace and tab/space mix
vim.api.nvim_set_hl(0, "WhiteSpaceEOL", { bg = "lightgreen" })
vim.fn.matchadd("WhiteSpaceEOL", [[\s\+$]])
vim.api.nvim_set_hl(0, "LeadingTabSpaceMix", { bg = "lightgreen" })
vim.fn.matchadd("LeadingTabSpaceMix", [[^\s*\(\t \)\|\( \t\)\s*]])
-- Quick-run current buffer
vim.keymap.set("n", "<leader>r", function()
local ft = vim.bo.filetype
local cmd = ({
java = "java %",
lua = "lua %",
python = "python %",
})[ft]
if cmd then
vim.cmd("!" .. cmd)
end
end, { desc = "[R]un current buffer" })