From a79b24e812b69a389864c188ad57439f8297d79c Mon Sep 17 00:00:00 2001 From: He4eT Date: Thu, 4 Apr 2024 00:32:19 +0200 Subject: [PATCH] nvim: lift up options --- nvim/init.lua | 263 +++++++++++++++++++++++++------------------------- 1 file changed, 129 insertions(+), 134 deletions(-) diff --git a/nvim/init.lua b/nvim/init.lua index c4bba15..3e06d82 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -8,6 +8,131 @@ vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) vim.keymap.set({ 'n', 'v' }, '', leader, { silent = true, remap = true }) vim.keymap.set({ 'n', 'v' }, '', '', { silent = true, remap = false }) +-- [[ Setting options ]] +-- See `:help vim.o` + +-- Set window title +vim.o.title = true +vim.o.titlestring = '%F' + +-- Hide mode in cmd +vim.o.showmode = false + +-- Set highlight on search +vim.o.hlsearch = true + +-- Make line numbers default +vim.wo.number = true + +-- Enable mouse mode +vim.o.mouse = 'a' + +-- Enable break indent +vim.o.breakindent = false + +-- Disable line wrapping +vim.o.wrap = false + +-- Break lines at word +vim.o.linebreak = true + +-- Show cursorline +vim.o.cursorline = true + +-- Keep signcolumn on by default +vim.wo.signcolumn = 'yes' + +-- Hide tildes on unused lines +vim.o.fillchars = 'eob: ' + +-- Save undo history +vim.o.undofile = true + +-- Case insensitive searching UNLESS /C or capital in search +vim.o.ignorecase = true +vim.o.smartcase = true + +-- Decrease update time +vim.o.updatetime = 250 +vim.o.timeout = false + +-- Set completeopt to have a better completion experience +vim.o.completeopt = 'menuone,noselect' + +-- Keeps the same screen lines in all split windows +vim.o.splitkeep = 'screen' + +-- Disable line numbers for terminal buffers +vim.api.nvim_create_autocmd({ 'TermOpen' }, { pattern = { '*' }, command = 'setlocal nonumber' }) + +-- Tune diagnostic signs +local signs = { Error = '■ ', Warn = '■ ', Hint = '■ ', Info = '■ ' } +for type, icon in pairs(signs) do + local hl = 'DiagnosticSign' .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) +end + +-- [[ Basic Keymaps ]] + +-- Remap for dealing with word wrap +vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) +vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) + +-- Remap PgUp/PgDown to C-u/C-d +vim.keymap.set('n', '', '', { silent = true }) +vim.keymap.set('n', '', '', { silent = true }) + +-- Open terminal +vim.keymap.set({ 'n' }, 't', ':terminali', { silent = true }) + +-- Escaping Terminal mode +vim.keymap.set({ 't' }, ';;', '', { silent = true }) + +-- Window managment +vim.keymap.set('n', 'w', '', { remap = true }) +vim.keymap.set('n', 'k', 'w', { remap = true }) +vim.keymap.set('n', 'K', ':vsw') +vim.keymap.set('n', 'q', ':b#|bd#') +vim.keymap.set('n', 'h', '') +vim.keymap.set('n', 'l', '') + +-- Copy'n'Paste +vim.keymap.set('n', 'y', ':call system("xclip -i -selection clipboard", @@)') +vim.keymap.set('v', 'y', '"+y') + +-- Diagnostic +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) +vim.keymap.set('n', 'd', vim.diagnostic.open_float, { desc = 'Open floating [d]iagnostic message' }) +vim.keymap.set('n', 'D', vim.diagnostic.setloclist, { desc = 'Open [D]iagnostics list' }) + +-- Gitsigns +vim.keymap.set('n', '[g', ':Gitsigns prev_hunk', { desc = 'Go to previous git hunk' }) +vim.keymap.set('n', ']g', ':Gitsigns next_hunk', { desc = 'Go to next git hunk' }) +vim.keymap.set('n', 'gb', ':Gitsigns blame_line', { desc = 'Show git blame' }) + +-- Highlight +vim.keymap.set({ 'n' }, '', ':nohl', { desc = 'Turn off highlight' }) + +-- Filetypes +vim.filetype.add { + extension = { + pcss = 'css', + }, +} + +-- [[ Highlight on yank ]] +-- See `:help vim.highlight.on_yank()` +local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) +vim.api.nvim_create_autocmd('TextYankPost', { + callback = function() + vim.highlight.on_yank() + end, + group = highlight_group, + pattern = '*', +}) + +-- [[ Lazy ]] -- Install package manager -- https://github.com/folke/lazy.nvim -- See `:help lazy.nvim.txt` for more info @@ -48,6 +173,10 @@ require('lazy').setup({ vim.g.desolate_warning = '#ffad29' vim.g.desolate_success = '#74af68' vim.g.desolate_info = '#ffffff' + + vim.o.termguicolors = true + vim.o.background = 'dark' + vim.cmd.colorscheme 'desolate' end, dependencies = { 'rktjmp/lush.nvim', @@ -193,134 +322,6 @@ require('lazy').setup({ }, }) --- [[ Setting options ]] --- See `:help vim.o` - --- Set window title -vim.o.title = true -vim.o.titlestring = '%F' - --- Hide mode in cmd -vim.o.showmode = false - --- Set highlight on search -vim.o.hlsearch = true - --- Make line numbers default -vim.wo.number = true - --- Enable mouse mode -vim.o.mouse = 'a' - --- Enable break indent -vim.o.breakindent = false - --- Disable line wrapping -vim.o.wrap = false - --- Break lines at word -vim.o.linebreak = true - --- Show cursorline -vim.o.cursorline = true - --- Keep signcolumn on by default -vim.wo.signcolumn = 'yes' - --- Hide tildes on unused lines -vim.o.fillchars = 'eob: ' - --- Save undo history -vim.o.undofile = true - --- Case insensitive searching UNLESS /C or capital in search -vim.o.ignorecase = true -vim.o.smartcase = true - --- Decrease update time -vim.o.updatetime = 250 -vim.o.timeout = false - --- Set completeopt to have a better completion experience -vim.o.completeopt = 'menuone,noselect' - --- Keeps the same screen lines in all split windows -vim.o.splitkeep = 'screen' - --- [[ Appearance ]] - --- NOTE: You should make sure your terminal supports this -vim.o.termguicolors = true - --- Set dark background -vim.o.background = 'dark' - --- Set colorscheme -vim.cmd.colorscheme 'desolate' - --- Disable line numbers for terminal buffers -vim.api.nvim_create_autocmd({ 'TermOpen' }, { pattern = { '*' }, command = 'setlocal nonumber' }) - --- Tune diagnostic signs -local signs = { Error = '■ ', Warn = '■ ', Hint = '■ ', Info = '■ ' } -for type, icon in pairs(signs) do - local hl = 'DiagnosticSign' .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) -end - --- [[ Basic Keymaps ]] - --- Remap for dealing with word wrap -vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) -vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) - --- Remap PgUp/PgDown to C-u/C-d -vim.keymap.set('n', '', '', { silent = true }) -vim.keymap.set('n', '', '', { silent = true }) - --- Open terminal -vim.keymap.set({ 'n' }, 't', ':terminali', { silent = true }) - --- Escaping Terminal mode -vim.keymap.set({ 't' }, ';;', '', { silent = true }) - --- Window managment -vim.keymap.set('n', 'w', '', { remap = true }) -vim.keymap.set('n', 'k', 'w', { remap = true }) -vim.keymap.set('n', 'K', ':vsw') -vim.keymap.set('n', 'q', ':b#|bd#') -vim.keymap.set('n', 'h', '') -vim.keymap.set('n', 'l', '') - --- Copy'n'Paste -vim.keymap.set('n', 'y', ':call system("xclip -i -selection clipboard", @@)') -vim.keymap.set('v', 'y', '"+y') - --- Diagnostic -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) -vim.keymap.set('n', 'd', vim.diagnostic.open_float, { desc = 'Open floating [d]iagnostic message' }) -vim.keymap.set('n', 'D', vim.diagnostic.setloclist, { desc = 'Open [D]iagnostics list' }) - --- Gitsigns -vim.keymap.set('n', '[g', ':Gitsigns prev_hunk', { desc = 'Go to previous git hunk' }) -vim.keymap.set('n', ']g', ':Gitsigns next_hunk', { desc = 'Go to next git hunk' }) -vim.keymap.set('n', 'gb', ':Gitsigns blame_line', { desc = 'Show git blame' }) - --- Highlight -vim.keymap.set({ 'n' }, '', ':nohl', { desc = 'Turn off highlight' }) - --- [[ Highlight on yank ]] --- See `:help vim.highlight.on_yank()` -local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) -vim.api.nvim_create_autocmd('TextYankPost', { - callback = function() - vim.highlight.on_yank() - end, - group = highlight_group, - pattern = '*', -}) - -- [[ Configure Leap ]] require('leap').add_default_mappings() require('leap').opts.highlight_unlabeled_phase_one_targets = true @@ -486,12 +487,6 @@ require('nvim-treesitter.configs').setup { }, } -vim.filetype.add { - extension = { - pcss = 'css', - }, -} - -- [[ LSP settings ]] -- This function gets run when an LSP connects to a particular buffer. local on_attach = function(_, bufnr)