summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/custom/config
diff options
context:
space:
mode:
authorKyren223 <ulmliad223@gmail.com>2024-07-24 14:45:21 +0300
committerKyren223 <ulmliad223@gmail.com>2024-07-24 14:45:21 +0300
commit3c4f03c439369bca263dcf410ff75049707ad55a (patch)
treebc29565dc92aaff69720462d33aaf7fb1023a700 /.config/nvim/lua/custom/config
parent7206468ebcc414b41427f05bfe90e6e818cf2de6 (diff)
refactor(neovim): moved plugin/ files to lua/custom/config
Diffstat (limited to '.config/nvim/lua/custom/config')
-rw-r--r--.config/nvim/lua/custom/config/autocmds.lua16
-rw-r--r--.config/nvim/lua/custom/config/keymaps.lua53
-rw-r--r--.config/nvim/lua/custom/config/options.lua46
3 files changed, 115 insertions, 0 deletions
diff --git a/.config/nvim/lua/custom/config/autocmds.lua b/.config/nvim/lua/custom/config/autocmds.lua
new file mode 100644
index 0000000..a9a9dc0
--- /dev/null
+++ b/.config/nvim/lua/custom/config/autocmds.lua
@@ -0,0 +1,16 @@
+vim.api.nvim_create_autocmd('TextYankPost', {
+ desc = 'Highlight when yanking text',
+ group = vim.api.nvim_create_augroup('highlight-yank', { clear = true }),
+ callback = function()
+ vim.highlight.on_yank()
+ end,
+})
+
+vim.api.nvim_create_autocmd('BufEnter', {
+ desc = 'Disable newlines on commented lines from continuing the comment',
+ group = vim.api.nvim_create_augroup('disable-comments-continuation', { clear = true }),
+ callback = function()
+ -- vim.opt_local.formatoptions:remove('r') -- no comments on enter
+ vim.opt_local.formatoptions:remove('o') -- no comments on `o` or `O`
+ end,
+})
diff --git a/.config/nvim/lua/custom/config/keymaps.lua b/.config/nvim/lua/custom/config/keymaps.lua
new file mode 100644
index 0000000..bc5c73e
--- /dev/null
+++ b/.config/nvim/lua/custom/config/keymaps.lua
@@ -0,0 +1,53 @@
+local set = vim.keymap.set
+local silent = { silent = true }
+---@param mode string|table
+---@param keymap string
+local function unbind(mode, keymap)
+ set(mode, keymap, function() end)
+end
+
+local function toggle_zen()
+ vim.cmd('Neotree close')
+ vim.cmd('Trouble todo close')
+ vim.cmd('UndotreeHide')
+end
+
+local function paste()
+ vim.fn.getreg('+')
+end
+
+-- Misc
+set({ 'n', 'i' }, '<C-a>', '<Esc>ggVG', { desc = 'Visually Highlight [A]ll' })
+set('n', '<Esc>', '<cmd>nohlsearch<CR>', silent)
+set({ 'i', 'c' }, '<C-v>', paste) -- FIXME: seems to not work
+set('n', '<leader>z', toggle_zen, { desc = '[Z]en Mode', silent = true })
+unbind({ 'i', 'n', 'v' }, '<C-r>')
+
+set('n', 'U', '<cmd>redo<cr>')
+set('i', '<C-z>', '<cmd>undo<cr>')
+set('i', '<C-z>', '<cmd>undo<cr>')
+set({ 'i', 'n', 'v' }, '<C-q>', '<cmd>wqa<cr>')
+
+-- Window Navigation - NO NEED BECAUSE IT CONFLICTS WITH TMUX
+-- set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
+-- set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the down window' })
+-- set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the up window' })
+-- set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
+
+-- Window resizing
+local resize = 2
+set({ 'n', 't' }, '<C-Left>', string.format('<cmd>vertical resize -%d<CR>', resize), { desc = 'Resize Left' })
+set({ 'n', 't' }, '<C-Up>', string.format('<cmd>resize -%d<CR>', resize), { desc = 'Resize Up' })
+set({ 'n', 't' }, '<C-Down>', string.format('<cmd>resize +%d<CR>', resize), { desc = 'Resize Down' })
+set({ 'n', 't' }, '<C-Right>', string.format('<cmd>vertical resize +%d<CR>', resize), { desc = 'Resize Right' })
+
+-- Keep selection after < and > in visual mode
+set('v', '<', '<gv')
+set('v', '>', '>gv')
+
+-- Execute lua file or line
+set('n', '<leader>x', '<cmd>.lua<CR>', { desc = 'Execute the current line' })
+set('n', '<leader><leader>x', '<cmd>source %<CR>', { desc = 'Execute the current file' })
+
+-- Reformats file using lsp
+set('n', '=', vim.lsp.buf.format, { desc = 'Format File' })
diff --git a/.config/nvim/lua/custom/config/options.lua b/.config/nvim/lua/custom/config/options.lua
new file mode 100644
index 0000000..9ee0fd0
--- /dev/null
+++ b/.config/nvim/lua/custom/config/options.lua
@@ -0,0 +1,46 @@
+-- System
+vim.g.have_nerd_font = true
+vim.opt.mouse = 'a' -- enable mouse
+vim.opt.clipboard = 'unnamedplus' -- use system clipboard
+vim.opt.undofile = true -- persist undo history by saving it to a file
+vim.opt.exrc = true -- WARNING: runs .nvim.lua in cwd, which may execute arbitrary code
+
+-- Tab
+vim.opt.expandtab = true -- convert tabs to spaces
+vim.opt.tabstop = 4 -- number of visual spaces per TAB
+vim.opt.softtabstop = 4 -- number of idfk tab when editing
+vim.opt.shiftwidth = 4 -- number of spaces to insert on tab
+
+-- UI
+vim.opt.signcolumn = 'auto:9'
+vim.opt.number = true
+vim.opt.relativenumber = true
+vim.opt.cursorline = true -- highlight current line
+vim.opt.splitright = true
+vim.opt.splitbelow = true
+vim.opt.showmode = false -- don't show mode, because lualine already does
+vim.opt.list = true
+vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' }
+vim.diagnostic.config({ signs = false }) -- disable signcolumn diagnostics
+vim.opt.fillchars:append({ diff = '╱' }) -- nicer diff view for filled spaces
+
+-- Searching
+vim.opt.hlsearch = true
+vim.opt.ignorecase = true
+vim.opt.smartcase = true
+
+-- Misc
+vim.opt_local.wrap = false
+vim.opt.wrap = false
+vim.opt.scrolloff = 8
+vim.opt.undofile = true
+vim.opt.termguicolors = true
+vim.opt.laststatus = 3 -- views can only be fully collapsed with the global statusline
+vim.opt.splitkeep = 'screen' -- for edgy.nvim
+vim.opt.inccommand = 'split' -- shows preview for commands like :%s/from/to
+
+-- Disable warnings for missing language providers
+vim.g.loaded_node_provider = 0
+vim.g.loaded_perl_provider = 0
+vim.g.loaded_ruby_provider = 0
+vim.g.loaded_python3_provider = 0