0require("worstprgr.remap")
1vim.cmd("syntax on")
3-- Enable Plugins
4vim.cmd('colorscheme rose-pine')
5require("proclist").setup()
7vim.opt.guicursor = 'n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20'
9-- Force Unix Linefeed
10--vim.opt.fileformats = {"unix"}
12-- Enable line numbers and relative line numbers
13vim.opt.number = true
14vim.opt.relativenumber = true
15vim.opt.colorcolumn = "100"
16vim.opt.cursorline = true
18-- Set tabstop and shiftwidth to 4
19vim.opt.tabstop = 4
20vim.opt.shiftwidth = 0
21vim.opt.softtabstop = -1
22vim.opt.shiftround = true
23vim.opt.expandtab = true
24vim.opt.smartindent = false
25vim.opt.autoindent = true
26vim.opt.cindent = false
28vim.opt.hlsearch = false
29vim.opt.incsearch = true
31-- Define listchars
32vim.opt.listchars = {
33 -- eol = "↵",
34 trail = "~",
35 tab = ">-",
36 nbsp = "␣"
37}
39-- Enable 'list' option
40vim.opt.list = true
42vim.g.netrw_liststyle = 3
44-- Rose Pine
45require('rose-pine').setup({
46 styles = {
47 italic = false
48 }
49})
51require("autoclose").setup()
53-- Having longer updatetime (default is 4000 ms = 4s) leads to noticeable
54-- delays and poor user experience
55vim.opt.updatetime = 300
57-- Always show the signcolumn, otherwise it would shift the text each time
58-- diagnostics appeared/became resolved
59vim.opt.signcolumn = "yes"
61local keyset = vim.keymap.set
62-- Autocomplete
63function _G.check_back_space()
64 local col = vim.fn.col('.') - 1
65 return col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') ~= nil
66end
68-- Highlight token occurrence
69vim.cmd([[
70 set hlsearch
71 augroup cursor_word_highlight
72 autocmd!
73 autocmd CursorMoved * silent! lua vim.cmd('set nohlsearch') | vim.cmd('set hlsearch')
74 augroup END
75]])
77-- Remove highlight
78vim.api.nvim_set_keymap('n', '<Esc>', ':if v:hlsearch | nohlsearch | endif<CR>', { noremap = true, silent = true })
80-- Toggle between `true` and `false`
81function _G.toggle_bool()
82 local word = vim.fn.expand("<cword>")
83 if word == "true" then
84 vim.cmd('normal! ciwfalse')
85 elseif word == "false" then
86 vim.cmd('normal! ciwtrue')
87 else
88 print("[Hint]: Not a boolean value")
89 end
90end
92vim.keymap.set('n', '<leader>b', toggle_bool, { noremap = true, silent = true })
95-- jai specific
96vim.filetype.add({
97 extension = {
98 jai = "jai",
99 },
100})
102vim.api.nvim_create_autocmd("FileType", {
103 pattern = "jai",
104 callback = function()
105 -- Tabs / formatting
106 vim.opt_local.commentstring = "//!%s"
107 vim.opt_local.indentexpr = "GetJaiIndent(v:lnum)"
108 vim.opt_local.autoindent = true
109 vim.opt_local.cindent = false
110 vim.opt_local.smartindent = false
111 vim.opt_local.shiftwidth = 4
112 vim.opt_local.indentkeys = "0{,0},0(,0),0[,0],o,O"
114 vim.cmd([[
115 function! GetJaiIndent(lnum) abort
116 let line = getline(a:lnum)
117 let prev = prevnonblank(a:lnum - 1)
118 let prevline = getline(prev)
120 if line =~# '^\s*[}\])]'
121 return indent(prev)
122 endif
124 if prevline =~# '[{(\[]\s*$'
125 return indent(prev) + &shiftwidth
126 endif
128 return indent(prev)
129 endfunction
130 ]])
131 end,
132})
135-- okroshka specific
136vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
137 pattern = { "*.okr", "*.okroshka" },
138 callback = function()
139 vim.bo.filetype = "okr"
140 end,
141})
143vim.api.nvim_create_autocmd("FileType", {
144 pattern = "okr",
145 callback = function()
146 -- Tabs / formatting
147 vim.opt_local.commentstring = "//!%s"
148 vim.opt_local.indentexpr = "GetOkrIndent(v:lnum)"
149 vim.opt_local.autoindent = true
150 vim.opt_local.cindent = false
151 vim.opt_local.smartindent = false
152 vim.opt_local.shiftwidth = 4
153 vim.opt_local.indentkeys = "0{,0},0(,0),0[,0],o,O"
155 vim.cmd([[
156 function! GetOkrIndent(lnum) abort
157 let line = getline(a:lnum)
158 let prev = prevnonblank(a:lnum - 1)
159 let prevline = getline(prev)
161 if line =~# '^\s*[}\])]'
162 return indent(prev)
163 endif
165 if prevline =~# '[{(\[]\s*$'
166 return indent(prev) + &shiftwidth
167 endif
169 return indent(prev)
170 endfunction
171 ]])
172 end,
173})
index : nvim-config
---