From 729730177f6a2373ab3ea44d80b4773e9cb7995c Mon Sep 17 00:00:00 2001 From: long Date: Fri, 26 Nov 2021 04:40:34 -0600 Subject: [PATCH] modified: init.lua modified: lua/config.lua new file: lua/functions.lua modified: lua/keybinds.lua modified: lua/plugins.lua --- init.lua | 6 +++-- lua/config.lua | 49 +++++++++++++++++++++++++++++++------- lua/functions.lua | 60 +++++++++++++++++++++++++++++++++++++++++++++++ lua/keybinds.lua | 23 +++++++++++++++--- lua/plugins.lua | 6 +++++ 5 files changed, 131 insertions(+), 13 deletions(-) create mode 100644 lua/functions.lua diff --git a/init.lua b/init.lua index 083f2bb..a2e41b4 100644 --- a/init.lua +++ b/init.lua @@ -12,6 +12,8 @@ require "lsp" --vim.g.onedark_terminal_italics = true --vim.opt.background = "light" --vim.opt.background = "dark" ---vim.cmd("colorscheme onedark") +vim.cmd("colorscheme onedark") ---vim.cmd("colorscheme github_dark") +--vim.cmd("colorscheme ghdark") +--vim.cmd("colorscheme github_dark_default") +--vim.cmd("colorscheme tokyonight") diff --git a/lua/config.lua b/lua/config.lua index 66de8be..e68c178 100644 --- a/lua/config.lua +++ b/lua/config.lua @@ -1,5 +1,7 @@ -- env file highlighting vim.cmd [[au BufRead,BufNewFile .env.* set filetype=sh]] +-- Dockerfile file highlighting +vim.cmd [[au BufRead,BufNewFile Dockerfile.* set filetype=dockerfile]] local opt = vim.opt -- to set options local fn = vim.fn @@ -44,6 +46,12 @@ opt.titlestring = [[NVIM: [%{fnamemodify(getcwd(), ':t')}] %t]] opt.cursorline = true opt.cursorcolumn = true +------------------ +-- ONEDARK.NVIM -- +------------------ +g.onedark_toggle_style_keymap = "" +--g.onedark_style = "cool" + ---------------- -- BCLOSE.VIM -- ---------------- @@ -66,12 +74,23 @@ require("nvim-treesitter.configs").setup { } } +----------------------- +-- GITHUB NVIM THEME -- +----------------------- +--require("github-theme").setup( +-- { +-- theme_style = "dark_default", +-- hide_inactive_statusline = false +-- } +--) +g.github_hide_inactive_statusline = false + ------------- -- LUALINE -- ------------- require("lualine").setup { - options = {theme = "github", icons_enabled = true}, + options = {theme = "onedark", icons_enabled = true}, sections = { lualine_a = {"mode"}, lualine_b = { @@ -107,7 +126,7 @@ require("lualine").setup { "buffers", show_filename_only = false, -- shows shortened relative path when false show_modified_status = true, -- shows indicator then bufder is modified - max_length = vim.o.columns * 1, -- maximum width of buffers component + max_length = vim.o.columns * 6 / 7, -- maximum width of buffers component filetype_names = { TelescopePrompt = "Telescope", dashboard = "Dashboard", @@ -132,18 +151,32 @@ require("lualine").setup { cond = function() return fn.tabpagenr("$") > 1 end + }, + { + [[harpoon_status()]], + cond = function() + return require("harpoon.mark").get_length() > 0 + end } } }, extensions = {} } ------------------------ --- GITHUB NVIM THEME -- ------------------------ -require("github-theme").setup( +------------- +-- HARPOON -- +------------- + +--Here is the set of global settings and their default values. + +require("harpoon").setup( { - theme_style = "dark_default", - hide_inactive_statusline = false + global_settings = { + save_on_toggle = false, + save_on_change = true, + enter_on_sendcmd = false, + tmux_autoclose_windows = false, + excluded_filetypes = {"harpoon"} + } } ) diff --git a/lua/functions.lua b/lua/functions.lua new file mode 100644 index 0000000..076c87c --- /dev/null +++ b/lua/functions.lua @@ -0,0 +1,60 @@ +-- Determines if harpoon_bnext and harpoon_bprevious +-- should switch between buffers or harpoon marks +-- `true` - harpoon +-- `false` - buffers +local function harpoon_tab_switch() + return require("harpoon.mark").get_length() > 1 +end + +-- Dynamically switches between bnext and harpoon.ui.nav_next +function _G.harpoon_bnext() + if harpoon_tab_switch() then + require("harpoon.ui").nav_next() + print("Harpoon nav_next") + else + vim.api.nvim_command("bnext") + print("bnext") + end +end + +-- Dynamically switches between bprevious and harpoon.ui.nav_prev +function _G.harpoon_bprevious() + if harpoon_tab_switch() then + require("harpoon.ui").nav_prev() + print("Harpoon nav_prev") + else + vim.api.nvim_command("bprevious") + print("bprevious") + end +end + +-- Runs harpoon.mark.toggle_file and refreshes lualine elements +function _G.harpoon_toggle_file() + require("harpoon.mark").toggle_file() + vim.api.nvim_command("redrawtabline") + vim.api.nvim_command("redrawstatus") +end + +function _G.harpoon_clear_all() + require("harpoon.mark").clear_all() + vim.api.nvim_command("redrawtabline") + vim.api.nvim_command("redrawstatus") +end + +-- I want my bclose bindings to also remove harpoon marks +function _G.harpoon_rm_file() + require("harpoon.mark").rm_file() + vim.api.nvim_command("Bclose") +end + +-- Lualine status element for harpoon +function _G.harpoon_status() + local marked_files = require("harpoon.mark").get_length() + local status_str = "Harpoon: %d file" + if marked_files > 1 then + status_str = status_str .. "s" + end + status_str = (harpoon_tab_switch() and "● " or "") .. status_str + return string.format(status_str, marked_files) +end +--[[string.format("Harpoon: %d files", require("harpoon.mark").get_length())]] diff --git a/lua/keybinds.lua b/lua/keybinds.lua index 8e08979..3e8dd9f 100644 --- a/lua/keybinds.lua +++ b/lua/keybinds.lua @@ -9,13 +9,17 @@ end vim.g.mapleader = "," +require("functions") + map("v", "", '"+y') -map("n", "", ":bnext") -map("n", "", ":bprevious") +--map("n", "", ":bnext") +--map("n", "", ":bprevious") +map("n", "", ":lua harpoon_bnext()") +map("n", "", ":lua harpoon_bprevious()") map("n", "", ":noh", {silent = true}) --After searching, pressing escape stops the highlight map("n", "w", [[:%s/\s\+$//e ]]) -map("n", "x", ":Bclose ") +--map("n", "x", ":Bclose ") map("n", "t", ":tabnew ") -- Split navigations @@ -77,3 +81,16 @@ map("n", "s", ":Rg ") --------- --map("n", "", ":ALEPreviousWrap ", {silent = true}) --map("n", "", ":ALENextWrap ", {silent = true}) + +------------- +-- HARPOON -- +------------- + +--map("n", "m", [[:lua require("harpoon.mark").add_file() ]]) +map("n", "x", ":lua harpoon_rm_file()") +map("n", "m", [[:lua harpoon_toggle_file()]]) +map("n", "M", [[:lua harpoon_clear_all()]]) +map("n", "l", [[:lua require("harpoon.ui").toggle_quick_menu()]]) + +--map("n", "n", [[:lua require("harpoon.ui").nav_next() ]]) +--map("n", "N", [[:lua require("harpoon.ui").nav_prev() ]]) diff --git a/lua/plugins.lua b/lua/plugins.lua index bd4d6f9..86c7de4 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -20,13 +20,17 @@ require("packer").startup( -- VIM THEMING --use "rafi/awesome-vim-colorschemes" -- vim themes + use "navarasu/onedark.nvim" use "projekt0n/github-nvim-theme" + use "wojciechkepka/vim-github-dark" + use "folke/tokyonight.nvim" -- FILE MANAGEMENT use "junegunn/fzf" use "junegunn/fzf.vim" use "rbgrouleff/bclose.vim" use "francoiscabrol/ranger.vim" + use "tpope/vim-fugitive" -- AIRLINE use { @@ -51,6 +55,8 @@ require("packer").startup( use "jose-elias-alvarez/nvim-lsp-ts-utils" use "jose-elias-alvarez/null-ls.nvim" + use "ThePrimeagen/harpoon" + use "L3MON4D3/LuaSnip" -- Snippets plugin use "hrsh7th/nvim-cmp" -- Autocompletion plugin use "saadparwaiz1/cmp_luasnip" -- Snippets source for nvim-cmp