Skip to content

Commit

Permalink
Fix the which-key spec issue caused by recent cleanup (nvim-lua#1113)
Browse files Browse the repository at this point in the history
The recent cleanup accidentally broke the leader key specs
because the spec block was in the wrong level of braces.
That resulted in which-key no longer showing the description
of the <leader> key chains such as [S]earch and others.
  • Loading branch information
dam9000 authored and giulianomindera committed Sep 10, 2024
1 parent 24d368f commit 27966bd
Show file tree
Hide file tree
Showing 5 changed files with 204 additions and 13 deletions.
55 changes: 43 additions & 12 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -310,17 +310,17 @@ require('lazy').setup({
F11 = '<F11>',
F12 = '<F12>',
},
},

-- Document existing key chains
spec = {
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
{ '<leader>d', group = '[D]ocument' },
{ '<leader>r', group = '[R]ename' },
{ '<leader>s', group = '[S]earch' },
{ '<leader>w', group = '[W]orkspace' },
{ '<leader>t', group = '[T]oggle' },
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
},
-- Document existing key chains
spec = {
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
{ '<leader>d', group = '[D]ocument' },
{ '<leader>r', group = '[R]ename' },
{ '<leader>s', group = '[S]earch' },
{ '<leader>w', group = '[W]orkspace' },
{ '<leader>t', group = '[T]oggle' },
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
},
},
},
Expand Down Expand Up @@ -354,7 +354,8 @@ require('lazy').setup({
{ 'nvim-telescope/telescope-ui-select.nvim' },

-- Useful for getting pretty icons, but requires a Nerd Font.
{ 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font },
-- { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font },
{ 'nvim-tree/nvim-web-devicons', enabled = true },
},
config = function()
-- Telescope is a fuzzy finder that comes with a lot of different things that
Expand Down Expand Up @@ -672,6 +673,7 @@ require('lazy').setup({
keys = {
{
'<leader>f',

function()
require('conform').format { async = true, lsp_format = 'fallback' }
end,
Expand Down Expand Up @@ -707,6 +709,25 @@ require('lazy').setup({
},
},
},
-- { -- Autoformat
-- 'stevearc/conform.nvim',
-- opts = {
-- notify_on_error = false,
-- format_on_save = {
-- timeout_ms = 500,
-- lsp_fallback = true,
-- },
-- formatters_by_ft = {
-- lua = { 'stylua' },
-- -- Conform can also run multiple formatters sequentially
-- -- python = { "isort", "black" },
-- --
-- -- You can use a sub-list to tell conform to run *until* a formatter
-- -- is found.
-- -- javascript = { { "prettierd", "prettier" } },
-- },
-- },
-- },

{ -- Autocompletion
'hrsh7th/nvim-cmp',
Expand Down Expand Up @@ -917,19 +938,24 @@ require('lazy').setup({
-- Here are some example plugins that I've included in the Kickstart repository.
-- Uncomment any of the lines below to enable them (you will need to restart nvim).
--
<<<<<<< HEAD
-- require 'kickstart.plugins.debug',
-- require 'kickstart.plugins.indent_line',
-- require 'kickstart.plugins.lint',
-- require 'kickstart.plugins.autopairs',
-- require 'kickstart.plugins.neo-tree',
-- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
=======
require 'kickstart.plugins.debug',
require 'kickstart.plugins.indent_line',
>>>>>>> e6e0663 (finish custom nvim)

-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
-- This is the easiest way to modularize your config.
--
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
-- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins`
-- { import = 'custom.plugins' },
{ import = 'custom.plugins' },
}, {
ui = {
-- If you are using a Nerd Font: set icons to an empty table which will use the
Expand All @@ -952,5 +978,10 @@ require('lazy').setup({
},
})

local has_other, other = pcall(require, 'custom.other')
if has_other then
other()
end

-- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et
111 changes: 111 additions & 0 deletions lua/custom/other.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
return function()
-- CUSTOM SETTINGS
-- Tab/Indentation settings
-- tabstop
-- The width of a hard tabstop measured in "spaces" -- effectively the (maximum) width of an actual tab character.
-- set something weird so it is not masqueraded
vim.opt.tabstop = 8

-- softtabstop
-- Setting this to a non-zero value other than tabstop will make the tab key (in insert mode) insert a combination of spaces (and possibly tabs) to simulate tab stops at this width.
vim.opt.softtabstop = 0

-- shiftwidth
-- The size of an "indent". It's also measured in spaces, so if your code base indents with tab characters then you want shiftwidth to equal the number of tab characters times tabstop. This is also used by things like the =, > and < commands.
vim.opt.shiftwidth = 2

-- expandtab
-- Enabling this will make the tab key (in insert mode) insert spaces instead of tab characters. This also affects the behavior of the retab command.
vim.opt.expandtab = true

-- smarttab
-- Enabling this will make the tab key (in insert mode) insert spaces or tabs to go to the next indent of the next tabstop when the cursor is at the beginning of a line (i.e. the only preceding characters are whitespace).
vim.opt.smarttab = true

--vim.opt.incsearch = true

--vim.opt.title = true
--vim.opt.scrolloff = 10
--vim.opt.inccommand = 'split'

--vim.opt.breakindent = true

--vim.opt.relativenumber = true

--vim.opt.wildignore:append { '*/node_modules/*' }

-- Backspace
--vim.opt.backspace = 'indent,eol,start'

-- Split windows
--vim.opt.splitright = true
--vim.opt.splitbelow = true

-- Consider dash `-` part of the word when using `dw`
--vim.opt.iskeyword:append('-')

-- Show tab-line even if only one tab
--vim.opt.showtabline = 2

-- Undercurl
--vim.cmd([[let &t_Cs = "\e[4:3m"]])
--vim.cmd([[let &t_Ce = "\e[4:0m"]])

-- KEYMAPS
local keymap = vim.keymap
-- PRIMEAGEN SETTINGS
--keymap.set('v', 'J', '>+1<CR>gv=gv')
--keymap.set('v', 'K', '<-2<CR>gv=gv')

-- Keep cursor aligned in middle while navigating
keymap.set('n', '<C-d>', '<C-d>zz')
keymap.set('n', '<C-u>', '<C-u>zz')
keymap.set('n', '<C-f>', '<C-f>zz')
keymap.set('n', '<C-b>', '<C-b>zz')

-- Replace word moving the word to the void register so it doesn't overwrite
-- the pasted value
--keymap.set('x', '<leader>p', '\'_dP')

-- Easily close tabs
keymap.set('n', 'Q', ':q<CR>')

-- Do no yank with x
--keymap.set('n', 'x', '"_x')
-- Delete a word backwards
-- keymap.set('n', 'dw', 'vb"_d')
-- Select all
--keymap.set('n', '<C-a>', 'gg<S-v>G')
-- New tab
--keymap.set('n', 'te', ':tabedit<CR>')
-- Split window
--keymap.set('n', '<space>\\', ':split<Return><C-w>w')
--keymap.set('n', '<space>-', ':vsplit<Return><C-w>w')

-- Easier save
--keymap.set({ 'n', 'i' }, '<C-a>', ':w<CR>')

-- Move window
--keymap.set('n', '<space>s<left>', '<C-w>h')
--keymap.set('n', '<space>s<up>', '<C-w>k')
--keymap.set('n', '<space>s<down>', '<C-w>j')
--keymap.set('n', '<space>s<right>', '<C-w>l')
--keymap.set('n', '<space>sh', '<C-w>h')
--keymap.set('n', '<space>sk', '<C-w>k')
--keymap.set('n', '<space>sj', '<C-w>j')
--keymap.set('n', '<space>sl', '<C-w>l')

-- keymap.set('n', '/', ':Neotree toggle current reveal_force_cwd<cr>')
keymap.set('n', '\\', ':Neotree toggle<CR>')
-- keymap.set('n', 'gd', ':Neotree float reveal_file=<cfile> reveal_force_cwd<cr>')
keymap.set('n', '|', ':Neotree toggle show buffers right<CR>')
-- keymap.set('n', '<leader>s', ':Neotree float git_status<CR>')
--
-- Map buffer switch to Tab and Shift + Tab
keymap.set('n', '<Tab>', ':bn!<CR>')
keymap.set('n', '<S-Tab>', ':bp!<CR>')
--
-- COLORS
-- vim.cmd('colorscheme citylights')
--vim.cmd('colorscheme transparent')
end
6 changes: 6 additions & 0 deletions lua/custom/plugins/autopairs.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
return {
'windwp/nvim-autopairs',
config = function()
require('nvim-autopairs').setup {}
end,
}
36 changes: 36 additions & 0 deletions lua/custom/plugins/filetree.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
-- Unless you are still migrating, remove the deprecated commands from v1.x
vim.cmd [[ let g:neo_tree_remove_legacy_commands = 1 ]]

return {
'nvim-neo-tree/neo-tree.nvim',
version = '*',
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended
'MunifTanjim/nui.nvim',
},
config = function()
require('neo-tree').setup {
filesystem = {
filtered_items = {
visible = true,
hide_dotfiles = false,
},
},
hijack_netrw_behavior = 'disabled',
}
end,
}

-- Change type
-- added = "", -- or "✚", but this is redundant info if you use git_status_colors on the name
-- modified = "", -- or "", but this is redundant info if you use git_status_colors on the name
-- deleted = "✖",-- this can only be used in the git_status source
-- renamed = "",-- this can only be used in the git_status source

-- Status type
-- untracked = "",
-- ignored = "",
-- unstaged = "",
-- staged = "",
-- conflict = "",
9 changes: 8 additions & 1 deletion lua/custom/plugins/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@
-- I promise not to create any merge conflicts in this directory :)
--
-- See the kickstart.nvim README for more information
return {}
return {
{
'akinsho/bufferline.nvim',
config = function()
require('bufferline').setup {}
end,
},
}

0 comments on commit 27966bd

Please sign in to comment.