From d9d98ca2c8643b4c5b8efba4c7264e04ececb883 Mon Sep 17 00:00:00 2001 From: Gabe Farrell Date: Sun, 14 Apr 2024 21:58:24 -0400 Subject: [PATCH] fix statusline + some lsp stuff --- README.md | 9 ++- init.lua | 10 ++- lua/configs/lazy.lua | 47 +++++++++++++ lua/configs/nvim-tree.lua | 79 +++++++++++++++++++++- lua/configs/treesitter.lua | 7 ++ lua/nvconfig.lua | 1 - lua/options.lua | 110 +++++++++++++++++-------------- lua/plugins/conform.lua | 1 - lua/plugins/indent-blankline.lua | 3 +- lua/plugins/lsp-zero.lua | 7 ++ lua/plugins/nvim-tree.lua | 4 +- lua/remaps.lua | 2 + 12 files changed, 218 insertions(+), 62 deletions(-) create mode 100644 lua/configs/lazy.lua diff --git a/README.md b/README.md index a147509..6f16db4 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,7 @@ -# my nvchad setup -copy this repo to ~/.config/nvim to nab my styles +# nvim stuff + +i like nvchad but i rewrote this to not use the distro anymore (but still using ui and bas46 plugin from chad :P) + +clone repo into ~./config to nab my styles + +note that base46 didnt work until i ran `require('base46').load_all_highlights()` manually diff --git a/init.lua b/init.lua index 48665a9..5c95abd 100644 --- a/init.lua +++ b/init.lua @@ -23,10 +23,12 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then } end vim.opt.rtp:prepend(lazypath) -require("lazy").setup { import = "plugins" } +local lazy_config = require "configs.lazy" +require("lazy").setup({ import = "plugins" }, lazy_config) -- more nvchad ui stuff -- dofile(vim.g.base46_cache .. "defaults") +-- dofile(vim.g.base46_cache .. "statusline") -- dofile(vim.g.base46_cache .. "syntax") -- dofile(vim.g.base46_cache .. "treesitter") -- dofile(vim.g.base46_cache .. "git") @@ -41,5 +43,7 @@ end vim.o.number = true -- require("nvim-tree.api").tree.open() -- open tree on start -require "options" -require "remaps" +-- vim.schedule(function() + require "options" + require "remaps" +-- end) diff --git a/lua/configs/lazy.lua b/lua/configs/lazy.lua new file mode 100644 index 0000000..cd170bd --- /dev/null +++ b/lua/configs/lazy.lua @@ -0,0 +1,47 @@ +return { + defaults = { lazy = true }, + install = { colorscheme = { "nvchad" } }, + + ui = { + icons = { + ft = "", + lazy = "󰂠 ", + loaded = "", + not_loaded = "", + }, + }, + + performance = { + rtp = { + disabled_plugins = { + "2html_plugin", + "tohtml", + "getscript", + "getscriptPlugin", + "gzip", + "logipat", + "netrw", + "netrwPlugin", + "netrwSettings", + "netrwFileHandlers", + "matchit", + "tar", + "tarPlugin", + "rrhelper", + "spellfile_plugin", + "vimball", + "vimballPlugin", + "zip", + "zipPlugin", + "tutor", + "rplugin", + "syntax", + "synmenu", + "optwin", + "compiler", + "bugreport", + "ftplugin", + }, + }, + }, +} diff --git a/lua/configs/nvim-tree.lua b/lua/configs/nvim-tree.lua index 0f7ef80..045d8d7 100644 --- a/lua/configs/nvim-tree.lua +++ b/lua/configs/nvim-tree.lua @@ -5,12 +5,67 @@ local function on_attach(bufnr) end local M = { - disable_netrw = true, on_attach = on_attach, - git = { ignore = false }, + filters = { + dotfiles = false, + }, + disable_netrw = true, + hijack_netrw = true, + hijack_cursor = true, + hijack_unnamed_buffer_when_opening = false, + sync_root_with_cwd = true, + update_focused_file = { + enable = true, + update_root = false, + }, + view = { + adaptive_size = false, + side = "left", + width = 30, + preserve_window_proportions = true, + }, + git = { + enable = true, + ignore = false, + }, + filesystem_watchers = { + enable = true, + }, + actions = { + open_file = { + resize_window = true, + }, + }, renderer = { + root_folder_label = false, + highlight_git = true, + highlight_opened_files = "none", + + indent_markers = { + enable = false, + }, + icons = { + show = { + file = true, + folder = true, + folder_arrow = true, + git = true, + }, + glyphs = { + default = "󰈚", + symlink = "", + folder = { + default = "", + empty = "", + empty_open = "", + open = "", + symlink = "", + symlink_open = "", + arrow_open = "", + arrow_closed = "", + }, git = { -- this is so stupid lmao unstaged = "😴", staged = "😎", @@ -24,4 +79,24 @@ local M = { }, } +-- local M = { +-- disable_netrw = true, +-- on_attach = on_attach, +-- git = { ignore = false }, +-- renderer = { +-- icons = { +-- glyphs = { +-- git = { -- this is so stupid lmao +-- unstaged = "😴", +-- staged = "😎", +-- unmerged = "😈", +-- untracked = "😭", +-- renamed = "😶", +-- deleted = "😵", +-- }, +-- }, +-- }, +-- }, +-- } + return M diff --git a/lua/configs/treesitter.lua b/lua/configs/treesitter.lua index 7d1fe77..d8851e6 100644 --- a/lua/configs/treesitter.lua +++ b/lua/configs/treesitter.lua @@ -6,9 +6,16 @@ return { "vim", "vimdoc", "go", + "gomod", "ruby", "rust", "cpp", + "javascript", + "typescript", + "html", + "css", + "astro", + "bash", }, highlight = { enable = true, diff --git a/lua/nvconfig.lua b/lua/nvconfig.lua index 0b5f446..c0c18cc 100644 --- a/lua/nvconfig.lua +++ b/lua/nvconfig.lua @@ -31,7 +31,6 @@ M.ui = { modules = nil, }, - -- lazyload it when there are 1+ buffers tabufline = { enabled = true, lazyload = false, diff --git a/lua/options.lua b/lua/options.lua index 04fe4fc..caaa658 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -1,53 +1,63 @@ -vim.o.mouse = "nv" -vim.o.mousemodel = "extend" - --- optimization for WSL --- vim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile" }, { --- once = true, --- callback = function() --- if vim.fn.has "win32" == 1 or vim.fn.has "wsl" == 1 then --- vim.g.clipboard = { --- copy = { --- ["+"] = "win32yank.exe -i --crlf", --- ["*"] = "win32yank.exe -i --crlf", --- }, --- paste = { --- ["+"] = "win32yank.exe -o --lf", --- ["*"] = "win32yank.exe -o --lf", --- }, --- } --- elseif vim.fn.has "unix" == 1 then --- if vim.fn.executable "xclip" == 1 then --- vim.g.clipboard = { --- copy = { --- ["+"] = "xclip -selection clipboard", --- ["*"] = "xclip -selection clipboard", --- }, --- paste = { --- ["+"] = "xclip -selection clipboard -o", --- ["*"] = "xclip -selection clipboard -o", --- }, --- } --- elseif vim.fn.executable "xsel" == 1 then --- vim.g.clipboard = { --- copy = { --- ["+"] = "xsel --clipboard --input", --- ["*"] = "xsel --clipboard --input", --- }, --- paste = { --- ["+"] = "xsel --clipboard --output", --- ["*"] = "xsel --clipboard --output", --- }, --- } --- end --- end --- vim.opt.clipboard = "unnamedplus" --- end, --- desc = "Lazy load clipboard", ---}) - --- enable cursor line -vim.o.cursorlineopt = "both" +local opt = vim.opt +local o = vim.o +local g = vim.g + +-------------------------------------- globals ----------------------------------------- +g.toggle_theme_icon = "  " + +-------------------------------------- options ------------------------------------------ +o.laststatus = 3 +o.showmode = false + +o.clipboard = "unnamedplus" +o.cursorline = true +o.cursorlineopt = "number" + +-- Indenting +o.expandtab = true +o.shiftwidth = 2 +o.smartindent = true +o.tabstop = 2 +o.softtabstop = 2 + +opt.fillchars = { eob = " " } +o.ignorecase = true +o.smartcase = true +o.mouse = "nv" +o.mousemodel = "extend" + +-- Numbers +o.number = true +o.numberwidth = 2 +o.ruler = false + +-- disable nvim intro +opt.shortmess:append "sI" + +o.signcolumn = "yes" +o.splitbelow = true +o.splitright = true +o.timeoutlen = 400 +o.undofile = true + +-- interval for writing swap file to disk, also used by gitsigns +o.updatetime = 250 + +-- go to previous/next line with h,l,left arrow and right arrow +-- when cursor reaches end/beginning of line +opt.whichwrap:append "<>[]hl" + +-- g.mapleader = " " + +-- disable some default providers +vim.g["loaded_node_provider"] = 0 +vim.g["loaded_python3_provider"] = 0 +vim.g["loaded_perl_provider"] = 0 +vim.g["loaded_ruby_provider"] = 0 + +-- add binaries installed by mason.nvim to path +local is_windows = vim.fn.has "win32" ~= 0 +vim.env.PATH = vim.fn.stdpath "data" .. "/mason/bin" .. (is_windows and ";" or ":") .. vim.env.PATH -- Highlight on yank vim.api.nvim_create_autocmd("TextYankPost", { diff --git a/lua/plugins/conform.lua b/lua/plugins/conform.lua index b3d28db..08c4c11 100644 --- a/lua/plugins/conform.lua +++ b/lua/plugins/conform.lua @@ -12,7 +12,6 @@ return { formatters_by_ft = { bash = { "shfmt" }, sh = { "shfmt" }, - fish = { "fish_indent" }, lua = { "stylua" }, go = { "goimports", "gofumpt", "goimports-reviser" }, javascript = { { "prettierd", "prettier" } }, diff --git a/lua/plugins/indent-blankline.lua b/lua/plugins/indent-blankline.lua index fcd0753..eb93ad0 100644 --- a/lua/plugins/indent-blankline.lua +++ b/lua/plugins/indent-blankline.lua @@ -1,13 +1,12 @@ return { "lukas-reineke/indent-blankline.nvim", + main = "ibl", event = "User FilePost", opts = { indent = { char = "│", highlight = "IblChar" }, scope = { char = "│", highlight = "IblScopeChar" }, }, config = function(_, opts) - dofile(vim.g.base46_cache .. "blankline") - local hooks = require "ibl.hooks" hooks.register(hooks.type.WHITESPACE, hooks.builtin.hide_first_space_indent_level) require("ibl").setup(opts) diff --git a/lua/plugins/lsp-zero.lua b/lua/plugins/lsp-zero.lua index 90e80c8..bd63319 100644 --- a/lua/plugins/lsp-zero.lua +++ b/lua/plugins/lsp-zero.lua @@ -32,6 +32,13 @@ return { handlers = { function(server_name) require("lspconfig")[server_name].setup {} + require("lspconfig").lua_ls.setup { + settings = { + Lua = { + diagnostics = { globals = { "vim" } }, + }, + }, + } end, }, } diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua index d1ce634..28c4929 100644 --- a/lua/plugins/nvim-tree.lua +++ b/lua/plugins/nvim-tree.lua @@ -8,7 +8,9 @@ return { opts = function() return { override = require "nvchad.icons.devicons" } end, - -- opts = {}, + opts = function() + require "configs.nvim-tree" + end, config = function(_, opts) dofile(vim.g.base46_cache .. "devicons") require("nvim-web-devicons").setup(opts) diff --git a/lua/remaps.lua b/lua/remaps.lua index b52d69f..d256b93 100644 --- a/lua/remaps.lua +++ b/lua/remaps.lua @@ -16,6 +16,8 @@ map("n", "pg", builtin.live_grep, { desc = "[p]roject [g]rep" }) map("n", "fb", builtin.buffers, { desc = "[f]ind [b]uffer" }) map("n", "fh", builtin.help_tags, { desc = "[f]ind [h]elp" }) map("n", "fg", "Telescope current_buffer_fuzzy_find", { desc = "[f]ile [g]rep" }) +map("n", "cm", "Telescope git_commits", { desc = "Telescope Git commits" }) +map("n", "gt", "Telescope git_status", { desc = "Telescope Git status" }) -- base46 maps map("n", "th", "Telescope themes", { desc = "[th]emes" })