From 9b578f964bf48613a7bfd3a94bf900f1f0caf570 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Sat, 17 Jan 2026 23:54:05 -0500 Subject: [PATCH] refactor config to follow nvchad conventions - Create separate config files for telescope and nvim-tree in lua/configs/ - Fix plugin syntax (requires -> dependencies for lazy.nvim) - Consolidate duplicate settings into appropriate files - Move plugin configs out of options.lua and mappings.lua - Clean up init.lua to only contain SQL autocmds Co-Authored-By: Claude Sonnet 4.5 --- init.lua | 16 +++------- lua/configs/nvimtree.lua | 43 +++++++++++++++++++++++++++ lua/configs/telescope.lua | 15 ++++++++++ lua/mappings.lua | 22 -------------- lua/options.lua | 61 +++++++-------------------------------- lua/plugins/init.lua | 22 +++++++------- 6 files changed, 83 insertions(+), 96 deletions(-) create mode 100644 lua/configs/nvimtree.lua create mode 100644 lua/configs/telescope.lua diff --git a/init.lua b/init.lua index d297ed2..bbbfad1 100644 --- a/init.lua +++ b/init.lua @@ -37,6 +37,7 @@ vim.schedule(function() end) ------added------------ +-- SQL-specific settings vim.api.nvim_create_autocmd("FileType", { pattern = "sql", callback = function() @@ -44,17 +45,8 @@ vim.api.nvim_create_autocmd("FileType", { end, }) -vim.opt.conceallevel = 1 -- or 0, or 2, depending on your preference - --- pgformatter +-- pgformatter for SQL files vim.api.nvim_create_autocmd("FileType", { - pattern = "sql", - -- command = "setlocal formatprg=/usr/local/bin/pg_format\\ --comma-start\\ -", - command = "setlocal formatprg=/usr/local/bin/pg_format\\ -", + pattern = "sql", + command = "setlocal formatprg=/usr/local/bin/pg_format\\ -", }) - --- set tab spacing -vim.opt.expandtab = true -- Use spaces instead of tabs -vim.opt.shiftwidth = 4 -- Number of spaces for each indentation level -vim.opt.tabstop = 4 -- Number of spaces a tab counts for -vim.opt.softtabstop = 4 -- Number of spaces a tab feels like when editing diff --git a/lua/configs/nvimtree.lua b/lua/configs/nvimtree.lua new file mode 100644 index 0000000..910ae81 --- /dev/null +++ b/lua/configs/nvimtree.lua @@ -0,0 +1,43 @@ +local options = { + filters = { + enable = true, + git_ignored = false, + dotfiles = false, + git_clean = false, + no_buffer = false, + no_bookmark = false, + custom = {}, + exclude = {}, + }, + disable_netrw = true, + hijack_cursor = true, + sync_root_with_cwd = true, + update_focused_file = { + enable = true, + update_root = false, + }, + view = { + width = 30, + preserve_window_proportions = true, + }, + renderer = { + root_folder_label = false, + highlight_git = true, + indent_markers = { enable = true }, + icons = { + glyphs = { + default = "󰈚", + folder = { + default = "", + empty = "", + empty_open = "", + open = "", + symlink = "", + }, + git = { unmerged = "" }, + }, + }, + }, +} + +return options diff --git a/lua/configs/telescope.lua b/lua/configs/telescope.lua new file mode 100644 index 0000000..dea15c9 --- /dev/null +++ b/lua/configs/telescope.lua @@ -0,0 +1,15 @@ +local actions = require('telescope.actions') + +require('telescope').setup { + defaults = { + layout_config = { + prompt_position = "top" + }, + mappings = { + i = { + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + }, + }, + }, +} diff --git a/lua/mappings.lua b/lua/mappings.lua index 52a3e42..fd1f41f 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -23,21 +23,6 @@ vim.api.nvim_set_keymap('v', 'fl', ':ObsidianLink', { noremap = true vim.api.nvim_set_keymap("n", "p1", "A 🔼", { noremap = true, silent = true }) vim.api.nvim_set_keymap("n", "p2", "A ⏫", { noremap = true, silent = true }) --- Configure Telescope to scroll files with ctrl+j/k -local actions = require('telescope.actions') --- local sorters = require('telescope.sorters') - -require('telescope').setup { - defaults = { - mappings = { - i = { - [""] = actions.move_selection_next, - [""] = actions.move_selection_previous, - }, - }, - }, -} - -- Live grep all files (including gitignored and hidden files) vim.keymap.set("n", "fW", function() require('telescope.builtin').live_grep({ @@ -61,13 +46,6 @@ vim.api.nvim_set_keymap('n', '', '5-', { silent = true }) vim.api.nvim_set_keymap('n', '', '10>', { silent = true }) vim.api.nvim_set_keymap('n', '', '10<', { silent = true }) --- Set the tab width to 4 spaces -vim.cmd('set tabstop=4') -vim.cmd('set shiftwidth=4') -vim.cmd('set expandtab') - -vim.o.hidden = true - -- wrap selected text in single quotes vim.keymap.set('x', "'", function() local text = vim.fn.getreg('"') -- Get the visually selected text diff --git a/lua/options.lua b/lua/options.lua index f153a94..f3f409f 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -2,55 +2,14 @@ require "nvchad.options" -- add yours here! --- local o = vim.o --- o.cursorlineopt ='both' -- to enable cursorline! -require('telescope').setup{ - defaults = { - layout_config = { - prompt_position = "top" - } - } -} +local opt = vim.opt -require('nvim-tree').setup{ - filters = { - enable = true, - git_ignored = false, - dotfiles = false, - git_clean = false, - no_buffer = false, - no_bookmark = false, - custom = {}, - exclude = {}, - }, - -- filters = { dotfiles = false }, - disable_netrw = true, - hijack_cursor = true, - sync_root_with_cwd = true, - update_focused_file = { - enable = true, - update_root = false, - }, - view = { - width = 30, - preserve_window_proportions = true, - }, - renderer = { - root_folder_label = false, - highlight_git = true, - indent_markers = { enable = true }, - icons = { - glyphs = { - default = "󰈚", - folder = { - default = "", - empty = "", - empty_open = "", - open = "", - symlink = "", - }, - git = { unmerged = "" }, - }, - }, - }, -} +-- Tab settings +opt.expandtab = true -- Use spaces instead of tabs +opt.shiftwidth = 4 -- Number of spaces for each indentation level +opt.tabstop = 4 -- Number of spaces a tab counts for +opt.softtabstop = 4 -- Number of spaces a tab feels like when editing + +-- Other options +opt.conceallevel = 1 -- Conceal level for markdown, etc. +opt.hidden = true -- Allow hidden buffers diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index e6c33fa..90ef158 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -5,7 +5,6 @@ return { opts = require "configs.conform", }, - -- These are some examples, uncomment them if you want to see them work! { "neovim/nvim-lspconfig", config = function() @@ -13,16 +12,17 @@ return { end, }, - { - 'nvim-telescope/telescope.nvim', - requires = { {'nvim-lua/plenary.nvim'} }, - config = function() - require('telescope').setup { - defaults = { - -- Your default configuration for Telescope (optional) - } - } - end + { + "nvim-tree/nvim-tree.lua", + opts = require "configs.nvimtree", + }, + + { + 'nvim-telescope/telescope.nvim', + dependencies = { 'nvim-lua/plenary.nvim' }, + config = function() + require "configs.telescope" + end }, { 'nvim-treesitter/nvim-treesitter',