require("worstprgr.remap") vim.cmd("syntax on") -- Enable Plugins vim.cmd('colorscheme rose-pine') require("proclist").setup() vim.opt.guicursor = 'n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20' -- Force Unix Linefeed --vim.opt.fileformats = {"unix"} -- Enable line numbers and relative line numbers vim.opt.number = true vim.opt.relativenumber = true vim.opt.colorcolumn = "100" vim.opt.cursorline = true -- Set tabstop and shiftwidth to 4 vim.opt.tabstop = 4 vim.opt.shiftwidth = 0 vim.opt.softtabstop = -1 vim.opt.shiftround = true vim.opt.expandtab = true vim.opt.smartindent = false vim.opt.autoindent = true vim.opt.cindent = false vim.opt.hlsearch = false vim.opt.incsearch = true -- Define listchars vim.opt.listchars = { -- eol = "↵", trail = "~", tab = ">-", nbsp = "␣" } -- Enable 'list' option vim.opt.list = true vim.g.netrw_liststyle = 3 -- Rose Pine require('rose-pine').setup({ styles = { italic = false } }) require("autoclose").setup() -- Having longer updatetime (default is 4000 ms = 4s) leads to noticeable -- delays and poor user experience vim.opt.updatetime = 300 -- Always show the signcolumn, otherwise it would shift the text each time -- diagnostics appeared/became resolved vim.opt.signcolumn = "yes" local keyset = vim.keymap.set -- Autocomplete function _G.check_back_space() local col = vim.fn.col('.') - 1 return col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') ~= nil end -- Highlight token occurrence vim.cmd([[ set hlsearch augroup cursor_word_highlight autocmd! autocmd CursorMoved * silent! lua vim.cmd('set nohlsearch') | vim.cmd('set hlsearch') augroup END ]]) -- Remove highlight vim.api.nvim_set_keymap('n', '', ':if v:hlsearch | nohlsearch | endif', { noremap = true, silent = true }) -- Toggle between `true` and `false` function _G.toggle_bool() local word = vim.fn.expand("") if word == "true" then vim.cmd('normal! ciwfalse') elseif word == "false" then vim.cmd('normal! ciwtrue') else print("[Hint]: Not a boolean value") end end vim.keymap.set('n', 'b', toggle_bool, { noremap = true, silent = true }) -- jai specific vim.filetype.add({ extension = { jai = "jai", }, }) vim.api.nvim_create_autocmd("FileType", { pattern = "jai", callback = function() -- Tabs / formatting vim.opt_local.commentstring = "//!%s" vim.opt_local.indentexpr = "GetJaiIndent(v:lnum)" vim.opt_local.autoindent = true vim.opt_local.cindent = false vim.opt_local.smartindent = false vim.opt_local.shiftwidth = 4 vim.opt_local.indentkeys = "0{,0},0(,0),0[,0],o,O" vim.cmd([[ function! GetJaiIndent(lnum) abort let line = getline(a:lnum) let prev = prevnonblank(a:lnum - 1) let prevline = getline(prev) if line =~# '^\s*[}\])]' return indent(prev) endif if prevline =~# '[{(\[]\s*$' return indent(prev) + &shiftwidth endif return indent(prev) endfunction ]]) end, }) -- okroshka specific vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { pattern = { "*.okr", "*.okroshka" }, callback = function() vim.bo.filetype = "okr" end, }) vim.api.nvim_create_autocmd("FileType", { pattern = "okr", callback = function() -- Tabs / formatting vim.opt_local.commentstring = "//!%s" vim.opt_local.indentexpr = "GetOkrIndent(v:lnum)" vim.opt_local.autoindent = true vim.opt_local.cindent = false vim.opt_local.smartindent = false vim.opt_local.shiftwidth = 4 vim.opt_local.indentkeys = "0{,0},0(,0),0[,0],o,O" vim.cmd([[ function! GetOkrIndent(lnum) abort let line = getline(a:lnum) let prev = prevnonblank(a:lnum - 1) let prevline = getline(prev) if line =~# '^\s*[}\])]' return indent(prev) endif if prevline =~# '[{(\[]\s*$' return indent(prev) + &shiftwidth endif return indent(prev) endfunction ]]) end, })