updated keymaps + added harpoon keymaps + scrolloff
This commit is contained in:
parent
0fd8713805
commit
f5a36a7b74
79
init.lua
79
init.lua
|
@ -1,42 +1,3 @@
|
|||
--[[
|
||||
|
||||
=====================================================================
|
||||
==================== READ THIS BEFORE CONTINUING ====================
|
||||
=====================================================================
|
||||
|
||||
Kickstart.nvim is *not* a distribution.
|
||||
|
||||
Kickstart.nvim is a template for your own configuration.
|
||||
The goal is that you can read every line of code, top-to-bottom, understand
|
||||
what your configuration is doing, and modify it to suit your needs.
|
||||
|
||||
Once you've done that, you should start exploring, configuring and tinkering to
|
||||
explore Neovim!
|
||||
|
||||
If you don't know anything about Lua, I recommend taking some time to read through
|
||||
a guide. One possible example:
|
||||
- https://learnxinyminutes.com/docs/lua/
|
||||
|
||||
|
||||
And then you can explore or search through `:help lua-guide`
|
||||
- https://neovim.io/doc/user/lua-guide.html
|
||||
|
||||
|
||||
Kickstart Guide:
|
||||
|
||||
I have left several `:help X` comments throughout the init.lua
|
||||
You should run that command and read that help section for more information.
|
||||
|
||||
In addition, I have some `NOTE:` items throughout the file.
|
||||
These are for you, the reader to help understand what is happening. Feel free to delete
|
||||
them once you know what you're doing, but they should serve as a guide for when you
|
||||
are first encountering a few different constructs in your nvim config.
|
||||
|
||||
I hope you enjoy your Neovim journey,
|
||||
- TJ
|
||||
|
||||
P.S. You can delete this when you're done too. It's your config now :)
|
||||
--]]
|
||||
-- Set <space> as the leader key
|
||||
-- See `:help mapleader`
|
||||
-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
|
||||
|
@ -373,11 +334,13 @@ end, { desc = '[/] Fuzzily search in current buffer' })
|
|||
|
||||
vim.keymap.set('n', '<leader>gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' })
|
||||
vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
|
||||
vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
|
||||
vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
|
||||
vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
|
||||
vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })
|
||||
vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc = '[S]earch [R]resume' })
|
||||
-- vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
|
||||
vim.keymap.set('n', '<leader>sh', require("harpoon.ui").toggle_quick_menu, { desc = '[S]earch [H]arpoon' })
|
||||
|
||||
|
||||
-- [[ Configure Treesitter ]]
|
||||
-- See `:help nvim-treesitter`
|
||||
|
@ -448,12 +411,12 @@ require('nvim-treesitter.configs').setup {
|
|||
-- Diagnostic keymaps
|
||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
|
||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })
|
||||
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
|
||||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
|
||||
vim.keymap.set('n', '<leader>dm', vim.diagnostic.open_float, { desc = 'Open floating [d]iagnostic [m]essage' })
|
||||
vim.keymap.set('n', '<leader>dl', vim.diagnostic.setloclist, { desc = 'Open [d]iagnostics [l]ist' })
|
||||
|
||||
-- Toggle diagnostics
|
||||
require('toggle_lsp_diagnostics').init()
|
||||
vim.keymap.set('n', '<leader>td', ':ToggleDiag<cr>', { desc = '[T]oggle [d]iagnostics' });
|
||||
vim.keymap.set('n', '<leader>dt', ':ToggleDiag<cr>', { desc = '[d]iagnostics [T]oggle' });
|
||||
|
||||
--vim.keymap.set('n', '<leader>td', require('toggle_lsp_diagnostics'))
|
||||
-- [[ Configure LSP ]]
|
||||
|
@ -473,15 +436,15 @@ local on_attach = function(_, bufnr)
|
|||
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
|
||||
end
|
||||
|
||||
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
|
||||
-- nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
|
||||
nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
|
||||
|
||||
nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
|
||||
nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
|
||||
nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
|
||||
nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
|
||||
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
|
||||
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
|
||||
-- nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
|
||||
-- nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
|
||||
-- nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
|
||||
|
||||
-- See `:help K` for why this keymap
|
||||
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
|
||||
|
@ -489,11 +452,13 @@ local on_attach = function(_, bufnr)
|
|||
|
||||
-- Lesser used LSP functionality
|
||||
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
|
||||
--[[
|
||||
nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
|
||||
nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
|
||||
nmap('<leader>wl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, '[W]orkspace [L]ist Folders')
|
||||
--]]
|
||||
|
||||
-- Create a command `:Format` local to the LSP buffer
|
||||
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
|
||||
|
@ -525,6 +490,21 @@ local servers = {
|
|||
},
|
||||
}
|
||||
|
||||
-- harpoon
|
||||
vim.keymap.set('n', '<leader>m', require("harpoon.mark").add_file, { desc = '[M]ark' });
|
||||
vim.keymap.set('n', '<leader>q', function()
|
||||
require("harpoon.ui").nav_file(1)
|
||||
end, { desc = '[q] Harpoon -> file number 1' })
|
||||
vim.keymap.set('n', '<leader>w', function()
|
||||
require("harpoon.ui").nav_file(2)
|
||||
end, { desc = '[q] Harpoon -> file number 2' })
|
||||
vim.keymap.set('n', '<leader>e', function()
|
||||
require("harpoon.ui").nav_file(3)
|
||||
end, { desc = '[q] Harpoon -> file number 3' })
|
||||
vim.keymap.set('n', '<leader>r', function()
|
||||
require("harpoon.ui").nav_file(4)
|
||||
end, { desc = '[q] Harpoon -> file number 4' })
|
||||
|
||||
-- Setup neovim lua configuration
|
||||
require('neodev').setup()
|
||||
|
||||
|
@ -599,7 +579,6 @@ cmp.setup {
|
|||
}
|
||||
|
||||
-- MY KEYMAPS --
|
||||
|
||||
-- exit insert mode with lk
|
||||
vim.keymap.set("i", "lk", "<esc>")
|
||||
|
||||
|
@ -609,6 +588,10 @@ vim.keymap.set("n", "<leader>x", vim.cmd.Ex)
|
|||
-- open fugitive in vertical split
|
||||
vim.keymap.set('n', '<leader>gs', ':vertical G<CR>')
|
||||
|
||||
-- MY SETTINGS --
|
||||
vim.opt.scrolloff = 10
|
||||
|
||||
|
||||
-- transparent bg
|
||||
--[[
|
||||
require("transparent").setup({ -- Optional, you don't have to run setup.
|
||||
|
|
Loading…
Reference in New Issue