From fd4a95bc362f117dad131006e567a1eb104661dc Mon Sep 17 00:00:00 2001 From: david Date: Wed, 20 Aug 2025 11:09:42 -0500 Subject: [PATCH] Set up LSP, completion, etc; adjust a few other small settings --- README.md | 3 - box_setup | 2 +- .../david_standard/colorscheme_settings.lua | 12 +- .../.config/nvim/lua/david_standard/init.lua | 28 +++- .../{remaps.lua => key_mappings.lua} | 0 .../nvim/lua/david_standard/lsp/ruby.lua | 6 + .../nvim/lua/david_standard/lsp_enables.lua | 10 ++ .../{lazy_nvim.lua => plugin_config.lua} | 1 + .../david_standard/plugin_key_mappings.lua | 44 +++--- .../plugins_lazy/conform_formatter.lua | 29 ++-- .../lua/david_standard/plugins_lazy/lsp.lua | 138 ++++++++++++++++++ .../plugins_lazy/treesitter.lua | 2 +- .../nvim/lua/david_standard/settings.lua | 2 +- src_files/.config/zsh/.zshrc | 2 +- 14 files changed, 231 insertions(+), 48 deletions(-) rename src_files/.config/nvim/lua/david_standard/{remaps.lua => key_mappings.lua} (100%) create mode 100644 src_files/.config/nvim/lua/david_standard/lsp/ruby.lua create mode 100644 src_files/.config/nvim/lua/david_standard/lsp_enables.lua rename src_files/.config/nvim/lua/david_standard/{lazy_nvim.lua => plugin_config.lua} (88%) create mode 100644 src_files/.config/nvim/lua/david_standard/plugins_lazy/lsp.lua diff --git a/README.md b/README.md index 4cc7478..f11f51c 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,6 @@ ### todo items - add logic to the main run script to handle cloning of this repo - add logic to the main run script to set `BOX_SETUP_OS` var, either input param or detect -- config for nvim - config for ghostty - config for mpd, mpc, ncmpcpp - config for mpv @@ -41,8 +40,6 @@ - set things in gtkrc only? still need to nest that within a sub dir? - or maybe just configure in gimp's gui, copy the whole resulting dir into `src_files/.config/GIMP` (edit out and delete what i don't need) and call it a day -- for whatever is causing it, editor/terminal/other, git rid of ligatures/name? - - for example, `>=` is two chars (`>` then `=`), not one char/symbol - decide on window manager for linux, then do config - look into xquartz for macos (x/xorg emulation or something?) - build in flags/logic for skipping certain installs/builds (and maybe configs?) on a diff --git a/box_setup b/box_setup index a610cdd..3620600 100755 --- a/box_setup +++ b/box_setup @@ -6,4 +6,4 @@ source ./src_files/.config/zsh/.zshenv ./copy_configs source $ZDOTDIR/.zshenv ; source $ZDOTDIR/.zshrc ./make_org_structure_dirs -./install_programs # TODO: moved this to after config copy, but does this work? +./install_programs # TODO: do installs overwrite configs? if so, fix; worst case, re-copy diff --git a/src_files/.config/nvim/lua/david_standard/colorscheme_settings.lua b/src_files/.config/nvim/lua/david_standard/colorscheme_settings.lua index 783c39e..2b23f68 100644 --- a/src_files/.config/nvim/lua/david_standard/colorscheme_settings.lua +++ b/src_files/.config/nvim/lua/david_standard/colorscheme_settings.lua @@ -1,22 +1,24 @@ function SetColorSchemeWrapper(scheme) - scheme = scheme or "sorbet" + scheme = scheme or "tokyonight-night" vim.cmd.colorscheme(scheme) - -- Allow for transparency + -- Allow for transparency -- TODO: do i actually want transparency? vim.api.nvim_set_hl(0, "Normal", { bg = "none" }) vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" }) end SetColorSchemeWrapper() --- TODO: get this working as desired --- autocmd('BufEnter', { --- group = ThePrimeagenGroup, -- TODO: group needed? +-- TODO: get this working as desired for different file types +-- local dsGroup = vim.api.nvim_create_augroup("DavidStandardGroup", { clear = false }) +-- vim.api.nvim_create_autocmd('BufEnter', { +-- group = dsGroup, -- callback = function() -- if vim.bo.filetype == "zig" then -- pcall(SetColorSchemeWrapper, "tokyonight-night") -- else -- pcall(SetColorSchemeWrapper, "rose-pine-main") -- pcall(SetColorSchemeWrapper, "slate") +-- pcall(SetColorSchemeWrapper, "sorbet") -- end -- end -- }) diff --git a/src_files/.config/nvim/lua/david_standard/init.lua b/src_files/.config/nvim/lua/david_standard/init.lua index eaedce9..bb91b75 100644 --- a/src_files/.config/nvim/lua/david_standard/init.lua +++ b/src_files/.config/nvim/lua/david_standard/init.lua @@ -1,15 +1,33 @@ -vim.api.nvim_create_augroup("DavidStandardGroup", { clear = true }) +local dsGroup = vim.api.nvim_create_augroup("DavidStandardGroup", { clear = true }) local dsgAutocmd = vim.api.nvim_create_autocmd require("david_standard.settings") -require("david_standard.remaps") -require("david_standard.lazy_nvim") - +require("david_standard.key_mappings") +require("david_standard.plugin_config") require("david_standard.plugin_key_mappings") require("david_standard.colorscheme_settings") +require("david_standard.lsp_enables") dsgAutocmd({"BufWritePre"}, { - group = DavidStandardGroup, + group = dsGroup, pattern = "*", command = [[%s/\s\+$//e]], }) + +-- TODO: put this into separate file(s) for lsp stuff? if so, pass in or make new autocmd +dsgAutocmd('LspAttach', { + group = dsGroup, + callback = function(e) + local opts = { buffer = e.buf } + vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts) + vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts) + vim.keymap.set("i", "", function() vim.lsp.buf.signature_help() end, opts) + vim.keymap.set("n", "vdv", function() vim.diagnostic.open_float() end, opts) + vim.keymap.set("n", "vdn", function() vim.diagnostic.goto_next() end, opts) + vim.keymap.set("n", "vdp", function() vim.diagnostic.goto_prev() end, opts) + vim.keymap.set("n", "vws", function() vim.lsp.buf.workspace_symbol() end, opts) + vim.keymap.set("n", "vca", function() vim.lsp.buf.code_action() end, opts) + vim.keymap.set("n", "vrl", function() vim.lsp.buf.references() end, opts) + vim.keymap.set("n", "vrn", function() vim.lsp.buf.rename() end, opts) + end +}) diff --git a/src_files/.config/nvim/lua/david_standard/remaps.lua b/src_files/.config/nvim/lua/david_standard/key_mappings.lua similarity index 100% rename from src_files/.config/nvim/lua/david_standard/remaps.lua rename to src_files/.config/nvim/lua/david_standard/key_mappings.lua diff --git a/src_files/.config/nvim/lua/david_standard/lsp/ruby.lua b/src_files/.config/nvim/lua/david_standard/lsp/ruby.lua new file mode 100644 index 0000000..fa1c5b6 --- /dev/null +++ b/src_files/.config/nvim/lua/david_standard/lsp/ruby.lua @@ -0,0 +1,6 @@ +return { + cmd = { "ruby-lsp" }, + filetypes = { "ruby", "eruby" }, + root_markers = { "Gemfile", ".git" }, + init_options = { formatter = "auto" }, +} diff --git a/src_files/.config/nvim/lua/david_standard/lsp_enables.lua b/src_files/.config/nvim/lua/david_standard/lsp_enables.lua new file mode 100644 index 0000000..c7473d1 --- /dev/null +++ b/src_files/.config/nvim/lua/david_standard/lsp_enables.lua @@ -0,0 +1,10 @@ +-- c + +-- c++ + +-- ruby +vim.lsp.enable('ruby_lsp') +-- vim.lsp.enable('typeprof') -- ruby builtin/official (but still labled experimental) +-- vim.lsp.enable('standardrb') +-- vim.lsp.enable('solargraph') +-- vim.lsp.enable('herb_ls') -- targets html + ruby (erb files) diff --git a/src_files/.config/nvim/lua/david_standard/lazy_nvim.lua b/src_files/.config/nvim/lua/david_standard/plugin_config.lua similarity index 88% rename from src_files/.config/nvim/lua/david_standard/lazy_nvim.lua rename to src_files/.config/nvim/lua/david_standard/plugin_config.lua index 735138d..4934154 100644 --- a/src_files/.config/nvim/lua/david_standard/lazy_nvim.lua +++ b/src_files/.config/nvim/lua/david_standard/plugin_config.lua @@ -1,3 +1,4 @@ +-- TODO: maybe switch this over from git-clone approach to neovim's builtin vim.pack.add local path_lazy_nvim = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not vim.loop.fs_stat(path_lazy_nvim) then local git_output = vim.fn.system({ diff --git a/src_files/.config/nvim/lua/david_standard/plugin_key_mappings.lua b/src_files/.config/nvim/lua/david_standard/plugin_key_mappings.lua index 89c3f61..dd21bb1 100644 --- a/src_files/.config/nvim/lua/david_standard/plugin_key_mappings.lua +++ b/src_files/.config/nvim/lua/david_standard/plugin_key_mappings.lua @@ -3,42 +3,52 @@ local builtin = require('telescope.builtin') local custom_tscope_grep = function() builtin.grep_string({ search = vim.fn.input("grep > ")}) end +vim.keymap.set('n', 'ft', builtin.live_grep, { + desc = 'Telescope find text (live_grep)' +}) +vim.keymap.set('n', 'fT', custom_tscope_grep, { + desc = 'Telescope find text (grep_string)' +}) +vim.keymap.set('n', 'fg', builtin.git_files, { + desc = 'Telescope find git-tracked files' +}) vim.keymap.set('n', 'ff', builtin.find_files, { desc = 'Telescope find files' }) -vim.keymap.set('n', 'ft', builtin.live_grep, { desc = 'Telescope find text (live_grep)' }) -vim.keymap.set('n', 'fT', custom_tscope_grep, { desc = 'Telescope find text (grep_string)' }) -vim.keymap.set('n', 'fg', builtin.git_files, { desc = 'Telescope find git-tracked files' }) vim.keymap.set('n', 'fb', builtin.buffers, { desc = 'Telescope buffers' }) vim.keymap.set('n', 'fh', builtin.help_tags, { desc = 'Telescope help tags' }) -- harpoon local harpoon = require("harpoon") +vim.keymap.set("n", "hl", function() + harpoon.ui:toggle_quick_menu(harpoon:list()) +end) vim.keymap.set("n", "ha", function() harpoon:list():add() end) vim.keymap.set("n", "hA", function() harpoon:list():prepend() end) -vim.keymap.set("n", "hl", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end) vim.keymap.set("n", "hn", function() harpoon:list():next() end) vim.keymap.set("n", "hp", function() harpoon:list():prev() end) -vim.keymap.set("n", "z", function() harpoon:list():select(1) end) -vim.keymap.set("n", "x", function() harpoon:list():select(2) end) -vim.keymap.set("n", "c", function() harpoon:list():select(3) end) -vim.keymap.set("n", "v", function() harpoon:list():select(4) end) -vim.keymap.set("n", "Z", function() harpoon:list():replace_at(1) end) -vim.keymap.set("n", "X", function() harpoon:list():replace_at(2) end) -vim.keymap.set("n", "C", function() harpoon:list():replace_at(3) end) -vim.keymap.set("n", "V", function() harpoon:list():replace_at(4) end) +vim.keymap.set("n", "hz", function() harpoon:list():select(1) end) +vim.keymap.set("n", "hx", function() harpoon:list():select(2) end) +vim.keymap.set("n", "hc", function() harpoon:list():select(3) end) +vim.keymap.set("n", "hv", function() harpoon:list():select(4) end) +vim.keymap.set("n", "hZ", function() harpoon:list():replace_at(1) end) +vim.keymap.set("n", "hX", function() harpoon:list():replace_at(2) end) +vim.keymap.set("n", "hC", function() harpoon:list():replace_at(3) end) +vim.keymap.set("n", "hV", function() harpoon:list():replace_at(4) end) -- undotree vim.keymap.set("n", "u", vim.cmd.UndotreeToggle) +-- treesitter and treesitter-context +vim.keymap.set("n", "tc", function() vim.cmd.TSContext({ "toggle" }) end) + -- fugitive (git integration) vim.keymap.set("n", "gG", vim.cmd.Git) vim.keymap.set("n", "gg", ":Git ") -- shortcut, arbitrary git commands vim.keymap.set("n", "ga", function() vim.cmd.Git({ "add %"}) end) -vim.keymap.set("n", "gs", function() vim.cmd.Git({ "--paginate status" }) end) +vim.keymap.set("n", "gs", function() vim.cmd.Git({ "-p status" }) end) vim.keymap.set("n", "gc", function() vim.cmd.Git({ "commit -a" }) end) -- conform (formatter) --- TODO: uncomment this once i set up the plugin --- vim.keymap.set("n", "fmt", function() --- require("conform").format({ bufnr = 0 }) --- end) +vim.keymap.set("n", "fmt", function() + require("conform").format({ bufnr = 0 }) +end) diff --git a/src_files/.config/nvim/lua/david_standard/plugins_lazy/conform_formatter.lua b/src_files/.config/nvim/lua/david_standard/plugins_lazy/conform_formatter.lua index 1c81b2e..c9349c2 100644 --- a/src_files/.config/nvim/lua/david_standard/plugins_lazy/conform_formatter.lua +++ b/src_files/.config/nvim/lua/david_standard/plugins_lazy/conform_formatter.lua @@ -1,17 +1,18 @@ --- TODO: set this up return { --- 'stevearc/conform.nvim', --- opts = {}, --- config = function() --- require("conform").setup({ --- formatters_by_ft = { --- lua = { "stylua" }, --- go = { "gofmt" }, --- javascript = { "prettier" }, --- typescript = { "prettier" }, --- elixir = { "mix" } --- } --- }) --- end + 'stevearc/conform.nvim', + opts = {}, + config = function() + require("conform").setup({ + formatters_by_ft = { + -- c = { "fill-in" }, + -- cpp = { "fill-in" }, + go = { "gofmt" }, + lua = { "stylua" }, + ruby = { "standardrb" }, + python = { "black" }, + javascript = { "prettier" }, + } + }) + end } diff --git a/src_files/.config/nvim/lua/david_standard/plugins_lazy/lsp.lua b/src_files/.config/nvim/lua/david_standard/plugins_lazy/lsp.lua new file mode 100644 index 0000000..ccc6515 --- /dev/null +++ b/src_files/.config/nvim/lua/david_standard/plugins_lazy/lsp.lua @@ -0,0 +1,138 @@ +return { + "neovim/nvim-lspconfig", + dependencies = { + "stevearc/conform.nvim", + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + "hrsh7th/nvim-cmp", + -- snippets, using luasnip for now + "L3MON4D3/LuaSnip", + "saadparwaiz1/cmp_luasnip", + }, + + config = function() + require("conform").setup({ formatters_by_ft = {} }) + local cmp = require('cmp') + local cmp_lsp = require("cmp_nvim_lsp") + local capabilities = vim.tbl_deep_extend( + "force", + {}, + vim.lsp.protocol.make_client_capabilities(), + cmp_lsp.default_capabilities() + ) + + require("mason").setup() + require("mason-lspconfig").setup({ + ensure_installed = { + "lua_ls", + -- "gopls", + "ruby_lsp", + -- "tailwindcss", + }, + handlers = { + function(server_name) -- default + require("lspconfig")[server_name].setup { + capabilities = capabilities + } + end, + + ["lua_ls"] = function() + local lspconfig = require("lspconfig") + lspconfig.lua_ls.setup { + capabilities = capabilities, + settings = { + Lua = { + format = { + enable = true, + defaultConfig = { -- NOTE: string values only + indent_style = "space", + indent_size = "2", + }, + }, + }, + }, + } + end, + } + }) + + local cmp_select = { behavior = cmp.SelectBehavior.Select } + cmp.setup({ + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.complete(), + [''] = cmp.mapping.confirm({ select = true }), + [''] = cmp.mapping.select_next_item(cmp_select), + [''] = cmp.mapping.select_prev_item(cmp_select), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + }), + snippet = { + expand = function(args) + -- vim.snippet.expand(args.body) -- TODO: native option, maybe try + require('luasnip').lsp_expand(args.body) + end, + }, + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, { + { name = 'buffer' }, + }), + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + }) + + -- `/` cmdline setup. + cmp.setup.cmdline('/', { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'buffer' } + } + }) + + -- `:` cmdline setup. + cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }), + matching = { disallow_symbol_nonprefix_matching = false } + }) + + + + + + + + + + + + + + + + + vim.diagnostic.config({ + -- update_in_insert = true, + float = { + focusable = false, + style = "minimal", + border = "rounded", + source = "always", + header = "", + prefix = "", + }, + }) + + end +} diff --git a/src_files/.config/nvim/lua/david_standard/plugins_lazy/treesitter.lua b/src_files/.config/nvim/lua/david_standard/plugins_lazy/treesitter.lua index 08eafb2..ee45c76 100644 --- a/src_files/.config/nvim/lua/david_standard/plugins_lazy/treesitter.lua +++ b/src_files/.config/nvim/lua/david_standard/plugins_lazy/treesitter.lua @@ -57,7 +57,7 @@ return { "nvim-treesitter/nvim-treesitter-context", after = "nvim-treesitter", opts = { - enable = true, -- can enable/disable via manual command + enable = false, -- can enable/disable via manual command multiwindow = false, max_lines = 0, -- lines the window should span; x <= 0 means no limit min_window_height = 10, -- min window height to enable; x <= 0 means no limit diff --git a/src_files/.config/nvim/lua/david_standard/settings.lua b/src_files/.config/nvim/lua/david_standard/settings.lua index dde6b0f..880c32d 100644 --- a/src_files/.config/nvim/lua/david_standard/settings.lua +++ b/src_files/.config/nvim/lua/david_standard/settings.lua @@ -10,7 +10,7 @@ vim.opt.incsearch = true vim.opt.termguicolors = true vim.opt.scrolloff = 2 vim.opt.colorcolumn = "90" -vim.opt.signcolumn = "number" -- "auto", "yes", "no", "number" +vim.opt.signcolumn = "yes" -- "auto", "yes", "no", "number" vim.opt.laststatus = 2 vim.opt.splitright = true vim.opt.splitbelow = true diff --git a/src_files/.config/zsh/.zshrc b/src_files/.config/zsh/.zshrc index 1152cf3..d56a233 100644 --- a/src_files/.config/zsh/.zshrc +++ b/src_files/.config/zsh/.zshrc @@ -2,7 +2,7 @@ set -o vi # path updates -export PATH=$DIR_BIN:$DIR_SCRIPTS:$PATH +export PATH=$DIR_BIN:$DIR_SCRIPTS:$PATH:$XDG_DATA_HOME export PATH=$PATH:/opt/homebrew/opt/ccache/libexec:/opt/homebrew/bin # shortcuts for common commands