Skip to content

Commit

Permalink
LSP and fzf-lua mappings (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
dycw authored Apr 14, 2024
1 parent b4f7d66 commit e7f791b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[bumpversion]
current_version = 0.1.90
current_version = 0.1.91
27 changes: 0 additions & 27 deletions lunarvim/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
-- key bindings
-------------------------------------------------------------------------------
-- LSP
lvim.keys.normal_mode["`j"] = "<Cmd>lua vim.diagnostic.goto_next()<CR>"
lvim.keys.normal_mode["`k"] = "<Cmd>lua vim.diagnostic.goto_prev()<CR>"
lvim.keys.normal_mode["R"] = {
function()
return ":IncRename " .. vim.fn.expand("<cword>")
Expand All @@ -16,10 +14,6 @@ lvim.keys.normal_mode["R"] = {
-------------------------------------------------------------------------------
-- key bindings (leader)
-------------------------------------------------------------------------------
-- iswap
lvim.builtin.which_key.mappings["i"] = { "<Cmd>ISwap<CR>", "ISwap" }
lvim.builtin.which_key.mappings["iw"] = { "<Cmd>ISwapWith<CR>", "ISwapWith" }

-- LSP
lvim.builtin.which_key.mappings["lR"] = { "<Cmd>LspRestart<CR>", "Restart LSP" }

Expand All @@ -29,24 +23,3 @@ lvim.builtin.which_key.mappings["mk"] = { "<Cmd>MergetoolDiffExchangeRight<CR>",
lvim.builtin.which_key.mappings["ml"] = { "<Cmd>MergetoolPreferLocal<CR>", "Prefer local" }
lvim.builtin.which_key.mappings["mr"] = { "<Cmd>MergetoolPreferRemote<CR>", "Prefer right" }
lvim.builtin.which_key.mappings["mq"] = { "<Cmd>MergetoolStop<CR>", "Stop" }

-- search text
lvim.builtin.which_key.mappings["g"] = {
function()
require("telescope.builtin").grep_string({
shorten_path = true,
word_match = "-w",
only_sort_text = true,
search = "",
})
end,
"Grep",
}

-- spectre
lvim.builtin.which_key.mappings["<Leader>sp"] = { "<Cmd>lua require('spectre').open()<CR>", "Spectre" }
lvim.builtin.which_key.mappings["<Leader>sf"] =
{ "<Cmd>lua require('spectre').open_file_search()<CR>", "Spectre (file)" }
lvim.builtin.which_key.vmappings["<Leader>sp"] = { "<Esc><Cmd>lua require('spectre').open_visual()<CR>", "Spectre" }
lvim.builtin.which_key.vmappings["<Leader>sf"] =
{ "<Esc><Cmd>lua require('spectre').open_file_search({select_word=true})<CR>", "Spectre (file)" }
6 changes: 0 additions & 6 deletions nvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ require("keymaps")
require("opts")
require("autocmds")

-- Diagnostic keymaps
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, { desc = "Go to previous [D]iagnostic message" })
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, { desc = "Go to next [D]iagnostic message" })
vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float, { desc = "Show diagnostic [E]rror messages" })
vim.keymap.set("n", "<leader>q", vim.diagnostic.setloclist, { desc = "Open diagnostic [Q]uickfix list" })

-- https://github.com/folke/lazy.nvim for more info
local lazypath = fn.stdpath("data") .. "/lazy/lazy.nvim"
if not v.loop.fs_stat(lazypath) then
Expand Down
13 changes: 9 additions & 4 deletions nvim/lua/custom/plugins/fzf-lua.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,30 @@ return {

fzf_lua.setup()
-- buffers and files
keymap_set("n", "<Leader><Leader>", fzf_lua.buffers, "Buffers")
keymap_set("n", "<Leader><Leader>", fzf_lua.buffers, "buffers")
keymap_set("n", "<Leader>al", fzf_lua.lines, "all [l]ines")
keymap_set("n", "<Leader>bl", fzf_lua.blines, "Buffer [l]ines")
keymap_set("n", "<Leader>of", fzf_lua.oldfiles, "old [f]iles")
keymap_set("n", "<Leader>qf", fzf_lua.quickfix, "quick [f]ix")
keymap_set("n", "<Leader>ta", fzf_lua.tabs, "T[a]bs")
-- search
keymap_set("n", "<Leader>/", fzf_lua.grep_curbuf, "grep buffer")
for _, value in ipairs({ { "\\", "grep project" }, { "gf", "g[r]ep project" } }) do
keymap_set("n", "<Leader>" .. value[1], fzf_lua.grep_project, value[2])
-- don't use grep, no good
end
keymap_set("n", "<Leader>gl", fzf_lua.grep_last, "grep [l]ast")
keymap_set("n", "<Leader>gr", fzf_lua.grep_project, "g[r]ep") -- grep no good
keymap_set("v", "<Leader>gr", fzf_lua.grep_visual, "g[r]ep")
keymap_set("n", "<Leader>gw", fzf_lua.grep_cword, "grep [w]ord")
keymap_set("n", "<Leader>gW", fzf_lua.grep_cWORD, "grep [W]ORD")
-- git
keymap_set("n", "<Leader>gc", fzf_lua.git_bcommits, "git buffer [c]ommits")
keymap_set("n", "<Leader>gf", fzf_lua.git_files, "git [f]iles")
for _, value in ipairs({ { "f", "[f]iles" }, { "gf", "git [f]iles" } }) do
keymap_set("n", "<Leader>" .. value[1], fzf_lua.git_files, value[2])
end
keymap_set("n", "<Leader>ga", fzf_lua.git_branches, "git br[a]nches")
keymap_set("n", "<Leader>gh", fzf_lua.git_status, "git stas[h]")
keymap_set("n", "<Leader>go", fzf_lua.git_commits, "git c[o]mmits")
keymap_set("n", "<Leader>gr", fzf_lua.git_branches, "git b[r]anches")
keymap_set("n", "<Leader>gs", fzf_lua.git_status, "git [s]tatus")
keymap_set("n", "<Leader>gt", fzf_lua.git_tags, "git [t]ags")
-- LSP
Expand Down
4 changes: 4 additions & 0 deletions nvim/lua/custom/plugins/nvim-lspconfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
local v = vim
-- luacheck: pop
local api = v.api
local diagnostic = v.diagnostic
local lsp = v.lsp
local buf = lsp.buf
local tbl_deep_extend = v.tbl_deep_extend
Expand All @@ -16,6 +17,9 @@ return { -- LSP Configuration & Plugins

-- Leader
keymap_set("n", "K", buf.hover, "hover documentation")
keymap_set("n", "zj", diagnostic.goto_next, "next diagnostic")
keymap_set("n", "zk", diagnostic.goto_prev, "previous diagnostic")
keymap_set("n", "<Leader>K", diagnostic.open_float, "open float")
keymap_set("n", "<Leader>rn", buf.rename, "re[n]ame")

-- WARN: This is not Goto Definition, this is Goto Declaration.
Expand Down

0 comments on commit e7f791b

Please sign in to comment.