diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index 1faf282..140f8c5 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -2,7 +2,7 @@ require('plugins') -- Key maps -require('keymaps') +require('mappings') -- Common settings require('settings') diff --git a/nvim/.config/nvim/lua/config/which.lua b/nvim/.config/nvim/lua/config/which.lua index 35d0f21..3a02630 100644 --- a/nvim/.config/nvim/lua/config/which.lua +++ b/nvim/.config/nvim/lua/config/which.lua @@ -1,4 +1,4 @@ --- disable v +--isable v -- local presets = require("which-key.plugins.presets") -- presets.operators["v"] = nil require("which-key").setup { @@ -63,8 +63,8 @@ require("which-key").setup { i = {"j", "k"}, v = {"j", "k"} } -} +} local wk = require("which-key") default_options = {noremap = true, silent = true} @@ -72,8 +72,17 @@ default_options = {noremap = true, silent = true} --wk.register({ga = {"(EasyAlign)", "Align", mode = "x"}}) -- Register all leader based mappings +local wk = require("which-key") +-- As an example, we will create the following mappings: +-- * ff find files +-- * fr show recent files +-- * fb Foobar +-- we'll document: +-- * fn new file +-- * fe edit file +-- and hide 1 wk.register({ - [""] = {"e#", "Switch to previously opened buffer"}, + [""] = { b = { name = "Buffers", b = { @@ -82,40 +91,15 @@ wk.register({ } }, f = { - name = "Files", - s = {"w", "Save Buffer"}, - f = { - "lua require'telescope.builtin'.find_files({ find_command = {'fd', '--hidden', '--type', 'file', '--follow'}})", - "Find File" - }, - l = {"Lf", "Open LF"}, - p = {"NvimTreeToggle", "Toogle Tree"}, - r = {"Telescope oldfiles", "Open Recent File"}, - T = {"NvimTreeFindFile", "Find in Tree"} + name = "File", + f = { "Telescope find_files", "Find File" }, + r = { "Telescope oldfiles", "Open Recent File" }, + n = { "enew", "New File" }, }, - s = { - name = "Search", - c = {"Telescope colorscheme", "Colorscheme"}, - h = {"Telescope help_tags", "Find Help"}, - M = {"Telescope man_pages", "Man Pages"}, - R = {"Telescope registers", "Registers"}, - t = {"Telescope live_grep", "Text"}, - s = {"Telescope grep_string", "Text under cursor"}, - k = {"Telescope keymaps", "Keymaps"}, - C = {"Telescope commands", "Commands"}, - p = {"Telescope projects", "Projects"}, - P = { - "lua require('telescope.builtin.internal').colorscheme({enable_preview = true})", - "Colorscheme with Preview" - } - }, - w = { - name = "Window", - q = {":q", "Close"}, - s = {":split", "Horizontal Split"}, - t = {"t", "Move to new tab"}, - ["="] = {"=", "Equally size"}, - v = {":vsplit", "Verstical Split"}, - w = {"x", "Swap"} - }, -}, {prefix = "", mode = "n", default_options}) + }, + s = { + name = "Search", + c = {"Telescope colorscheme", "Colorscheme" } + } + +}) diff --git a/nvim/.config/nvim/lua/keymaps.lua b/nvim/.config/nvim/lua/keymaps.lua deleted file mode 100644 index 981dd4d..0000000 --- a/nvim/.config/nvim/lua/keymaps.lua +++ /dev/null @@ -1,28 +0,0 @@ -local keymap = vim.api.nvim_set_keymap -default_options = {noremap = true, silent = true} -expr_options = {noremap = true, expr = true, silent = true} - --- map the leader key ---keymap('n', '', '', default_options) -vim.g.mapleader = "," - --- easier escape key mapping -keymap('i', 'jk', '', default_options) - -keymap('n', '', ':w', default_options) -keymap('i', '', ':wa', default_options) - --- buffer focus -local opts = { noremap = true } -keymap('n', '', 'j', default_options) -keymap('n', '', 'h', default_options) -keymap('n', '', 'k', default_options) -keymap('n', '', 'l', default_options) - --- refresh config ---keymap('n', 'so', ':so $MYVIMRC', default_opts) - ---keymap('n', '', ':NvimTreeToggle', default_opts) --- find files ---keymap('n', 'f', ':Telescope find_files', default_opts) - diff --git a/nvim/.config/nvim/lua/mappings.lua b/nvim/.config/nvim/lua/mappings.lua new file mode 100644 index 0000000..0095fb6 --- /dev/null +++ b/nvim/.config/nvim/lua/mappings.lua @@ -0,0 +1,33 @@ +local keymap = vim.api.nvim_set_keymap +default_options = {noremap = true, silent = true} +expr_options = {noremap = true, expr = true, silent = true} + +-- map the leader key +keymap('n', '', '', default_options) +vim.g.mapleader = " " + +-- easier escape key mapping +keymap('i', 'jk', '', default_options) + +keymap('n', '', ':w', default_options) +keymap('i', '', ':wa', default_options) + +-- paste over currently selected text without yanking it +keymap("v", "p", "\"_dP", default_options) + +-- buffer focus +local opts = { noremap = true } +keymap('n', '', 'j', default_options) +keymap('n', '', 'h', default_options) +keymap('n', '', 'k', default_options) +keymap('n', '', 'l', default_options) + +-- Resizing panes +keymap("n", "", ":vertical resize +1", default_options) +keymap("n", "", ":vertical resize -1", default_options) +keymap("n", "", ":resize -1", default_options) +keymap("n", "", ":resize +1", default_options) + +-- Move selected line / block of text in visual mode +keymap("x", "K", ":move '<-2gv-gv", default_options) +keymap("x", "J", ":move '>+1gv-gv", default_options) diff --git a/nvim/.config/nvim/lua/theme.lua b/nvim/.config/nvim/lua/theme.lua index a5b3226..941a7bd 100644 --- a/nvim/.config/nvim/lua/theme.lua +++ b/nvim/.config/nvim/lua/theme.lua @@ -1,24 +1,3 @@ -- Nightfox require('nightfox').load('nordfox') --- Tokyo Night --- Example config in Lua ---vim.g.tokyonight_style = "storm" ---vim.g.tokyonight_italic_functions = true ---vim.g.tokyonight_sidebars = { "qf", "vista_kind", "terminal", "packer" } - --- Change the "hint" color to the "orange" color, and make the "error" color bright red ---vim.g.tokyonight_colors = { hint = "orange", error = "#ff0000" } - --- Load the colorscheme ---vim.cmd[[colorscheme tokyonight]] - --- Nord --- Example config in lua ---vim.g.nord_contrast = true ---vim.g.nord_borders = false ---vim.g.nord_disable_background = false ---vim.g.nord_italic = false - --- Load the colorscheme ---require('nord').set() diff --git a/nvim/.config/nvim/plugin/packer_compiled.lua b/nvim/.config/nvim/plugin/packer_compiled.lua index 991d62a..1397318 100644 --- a/nvim/.config/nvim/plugin/packer_compiled.lua +++ b/nvim/.config/nvim/plugin/packer_compiled.lua @@ -87,6 +87,17 @@ _G.packer_plugins = { path = "/Users/michael/.local/share/nvim/site/pack/packer/start/nvim-tree.lua", url = "https://github.com/kyazdani42/nvim-tree.lua" }, + ["nvim-treesitter"] = { + config = { 'require("config/treesitter")' }, + loaded = true, + path = "/Users/michael/.local/share/nvim/site/pack/packer/start/nvim-treesitter", + url = "https://github.com/nvim-treesitter/nvim-treesitter" + }, + ["nvim-treesitter-textobjects"] = { + loaded = true, + path = "/Users/michael/.local/share/nvim/site/pack/packer/start/nvim-treesitter-textobjects", + url = "https://github.com/nvim-treesitter/nvim-treesitter-textobjects" + }, ["nvim-web-devicons"] = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/nvim-web-devicons", @@ -107,14 +118,22 @@ _G.packer_plugins = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/telescope.nvim", url = "https://github.com/nvim-telescope/telescope.nvim" + }, + ["which-key.nvim"] = { + config = { 'require("config/which")' }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/Users/michael/.local/share/nvim/site/pack/packer/opt/which-key.nvim", + url = "https://github.com/folke/which-key.nvim" } } time([[Defining packer_plugins]], false) --- Config for: nvim-tree.lua -time([[Config for nvim-tree.lua]], true) -require("config/nvim-tree") -time([[Config for nvim-tree.lua]], false) +-- Config for: lualine.nvim +time([[Config for lualine.nvim]], true) +require("config/lualine") +time([[Config for lualine.nvim]], false) -- Config for: nightfox.nvim time([[Config for nightfox.nvim]], true) require("config/nightfox") @@ -123,10 +142,21 @@ time([[Config for nightfox.nvim]], false) time([[Config for telescope.nvim]], true) require("config/telescope") time([[Config for telescope.nvim]], false) --- Config for: lualine.nvim -time([[Config for lualine.nvim]], true) -require("config/lualine") -time([[Config for lualine.nvim]], false) +-- Config for: nvim-treesitter +time([[Config for nvim-treesitter]], true) +require("config/treesitter") +time([[Config for nvim-treesitter]], false) +-- Config for: nvim-tree.lua +time([[Config for nvim-tree.lua]], true) +require("config/nvim-tree") +time([[Config for nvim-tree.lua]], false) +vim.cmd [[augroup packer_load_aucmds]] +vim.cmd [[au!]] + -- Event lazy-loads +time([[Defining lazy-load event autocommands]], true) +vim.cmd [[au VimEnter * ++once lua require("packer.load")({'which-key.nvim'}, { event = "VimEnter *" }, _G.packer_plugins)]] +time([[Defining lazy-load event autocommands]], false) +vim.cmd("augroup END") if should_profile then save_profiles() end end)