From 3831de930ca772a60303e8e5711aae94929ee6ab Mon Sep 17 00:00:00 2001 From: Nick Burt Date: Mon, 8 Jan 2024 19:10:02 -0600 Subject: [PATCH] refactor vim options into new file --- init.lua | 74 ++---------------------------------------------- lua/settings.lua | 72 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 72 deletions(-) create mode 100644 lua/settings.lua diff --git a/init.lua b/init.lua index a4818e3c..288ce8f2 100644 --- a/init.lua +++ b/init.lua @@ -13,79 +13,9 @@ if not vim.loop.fs_stat(lazypath) then } end vim.opt.rtp:prepend(lazypath) + require('lazy').setup('plugins'); - --- [[ Setting options ]] - --- Line numbers -vim.opt.nu = true -vim.opt.relativenumber = true - --- Highlighting on search -vim.opt.hlsearch = true -vim.opt.incsearch = true - --- Enable mouse mode -vim.opt.mouse = '' - --- Sync clipboard between OS and Neovim. -vim.opt.clipboard = 'unnamedplus' - --- Handle indentation -vim.opt.tabstop = 4 -vim.opt.softtabstop = 4 -vim.opt.shiftwidth = 4 -vim.opt.expandtab = true -vim.opt.smartindent = true -vim.opt.breakindent = true - --- Remove line wrapping -vim.opt.wrap = false - --- Scroll buffer -vim.opt.scrolloff = 8 - --- Save undo history -vim.o.undofile = true - --- Case-insensitive searching UNLESS \C or capital in search -vim.o.ignorecase = true -vim.o.smartcase = true - --- Keep signcolumn on by default -vim.wo.signcolumn = 'yes' - --- Decrease update time -vim.o.updatetime = 250 -vim.o.timeoutlen = 300 - --- Set completeopt to have a better completion experience -vim.o.completeopt = 'menuone,noselect' - -vim.o.termguicolors = true - --- [[ Basic Keymaps ]] -vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) - --- 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 }) - --- Diagnostic keymaps -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', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) - --- [[ 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 = '*', -}) +require('lua/settings'); -- [[ Configure Telescope ]] require('telescope').setup { diff --git a/lua/settings.lua b/lua/settings.lua new file mode 100644 index 00000000..905f368f --- /dev/null +++ b/lua/settings.lua @@ -0,0 +1,72 @@ +-- Line numbers +vim.opt.nu = true +vim.opt.relativenumber = true + +-- Highlighting on search +vim.opt.hlsearch = true +vim.opt.incsearch = true + +-- Enable mouse mode +vim.opt.mouse = '' + +-- FIX: shared clipboard not working +-- Sync clipboard between OS and Neovim. +vim.opt.clipboard = 'unnamedplus' + +-- FIX: tabs do not seem to be working as expected +-- Handle indentation +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true +vim.opt.smartindent = true +vim.opt.breakindent = true + +-- Remove line wrapping +vim.opt.wrap = false + +-- Scroll buffer +vim.opt.scrolloff = 8 + +-- Save undo history +vim.o.undofile = true + +-- Case-insensitive searching UNLESS \C or capital in search +vim.o.ignorecase = true +vim.o.smartcase = true + +-- Keep signcolumn on by default +vim.wo.signcolumn = 'yes' + +-- Decrease update time +vim.o.updatetime = 250 +vim.o.timeoutlen = 300 + +-- Set completeopt to have a better completion experience +vim.o.completeopt = 'menuone,noselect' + +vim.o.termguicolors = true + +-- [[ Basic Keymaps ]] +vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) + +-- 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 }) + +-- Diagnostic keymaps +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', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) + +-- 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 = '*', +}) +