133 lines
3.0 KiB
Lua
133 lines
3.0 KiB
Lua
local misc = require('core.misc')
|
|
local auto = misc.auto
|
|
|
|
-- color stuff
|
|
if vim.fn.has("termguicolors") then
|
|
vim.opt.termguicolors = true
|
|
end
|
|
|
|
vim.opt.laststatus = 3
|
|
|
|
-- numbers
|
|
vim.opt.number = true
|
|
vim.opt.relativenumber = true
|
|
|
|
-- buffer
|
|
vim.opt.scrolloff = 5
|
|
vim.opt.wrap = true -- wraping lines
|
|
vim.opt.linebreak = true -- fix where line is wraped
|
|
vim.opt.cursorline = true
|
|
|
|
-- indents + tabs
|
|
local tabwidth = 2
|
|
vim.opt.expandtab = true
|
|
vim.opt.smarttab = true
|
|
vim.opt.cindent = true
|
|
vim.opt.autoindent = true
|
|
vim.opt.tabstop = tabwidth
|
|
vim.opt.shiftwidth = tabwidth
|
|
vim.opt.softtabstop = tabwidth
|
|
|
|
-- Schedule the setting after `UiEnter` because it can increase startup-time.
|
|
-- (yoinked from kickstart.nvim)
|
|
vim.schedule(function()
|
|
vim.opt.clipboard = 'unnamedplus' -- system clipboard
|
|
end)
|
|
|
|
vim.opt.updatetime = 200
|
|
|
|
-- file saving
|
|
vim.opt.swapfile = false
|
|
vim.opt.undofile = true
|
|
vim.opt.confirm = true
|
|
|
|
-- searching
|
|
vim.opt.ignorecase = true
|
|
vim.opt.smartcase = true
|
|
vim.opt.wrapscan = true
|
|
vim.opt.showmatch = true
|
|
vim.opt.incsearch = true
|
|
|
|
-- wild menus
|
|
vim.opt.wildoptions = 'pum'
|
|
vim.opt.pumblend = 3
|
|
vim.opt.pumheight = 20
|
|
|
|
vim.opt.wildignorecase = true
|
|
vim.opt.wildignore = '*.o'
|
|
|
|
-- netrw
|
|
vim.g.netrw_banner = 0
|
|
vim.g.netrw_winsize = 30
|
|
vim.g.netrw_liststyle = 1
|
|
vim.g.netrw_sizestyle = "H"
|
|
vim.g.netrw_hide = 1
|
|
|
|
-- folding
|
|
auto("FileType", {
|
|
callback = function()
|
|
-- support lsp folding
|
|
if vim.fn.has("nvim-0.11") then
|
|
auto('LspAttach', {
|
|
callback = function(args)
|
|
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
|
if not client then
|
|
return
|
|
end
|
|
|
|
if client:supports_method('textDocument/foldingRange') then
|
|
local win = vim.api.nvim_get_current_win()
|
|
vim.wo[win][0].foldmethod = "expr"
|
|
vim.wo[win][0].foldexpr = 'v:lua.vim.lsp.foldexpr()'
|
|
end
|
|
end,
|
|
})
|
|
end
|
|
|
|
-- or just rely on treesitter
|
|
if require("nvim-treesitter.parsers").has_parser() then
|
|
vim.opt.foldmethod = "expr"
|
|
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
|
|
else
|
|
vim.opt.foldmethod = "syntax"
|
|
end
|
|
end
|
|
})
|
|
|
|
-- lsp folding: vim.o.foldexpr = "v:lua.vim.lsp.foldexpr()"
|
|
-- waiting on https://github.com/neovim/neovim/pull/31311 to hit a release
|
|
require('core.lsp.functions').add_capabilities({
|
|
textDocument = {
|
|
foldingRange = {
|
|
dynamicRegistration = false,
|
|
lineFoldingOnly = true
|
|
}
|
|
}
|
|
})
|
|
|
|
vim.opt.foldlevelstart = 99
|
|
vim.opt.foldlevel = 99
|
|
vim.opt.foldenable = true
|
|
vim.o.fillchars = 'fold: '
|
|
|
|
_G.Fold_text = require('core.folding')
|
|
vim.opt.foldtext = 'v:lua.Fold_text()'
|
|
|
|
-- statusline
|
|
function _G.Status()
|
|
return table.concat {
|
|
"%t", -- file name
|
|
" %h", -- help buffer tag
|
|
"%m", -- modify tag
|
|
"%r", -- readonly flag
|
|
"%=", -- seperate left and right side
|
|
|
|
-- print out the number of lsp clients attached
|
|
"λ"..#vim.lsp.get_clients({ bufnr = 0 }).." ",
|
|
|
|
"%l,%c%V", -- line, column-virtual column
|
|
" %P" -- percentage through display window
|
|
}
|
|
end
|
|
vim.o.statusline="%!v:lua.Status()"
|