in progress: improving nvim workflow without system wide keybinds
This commit is contained in:
parent
641624c70f
commit
20f6897ab4
10 changed files with 299 additions and 29 deletions
7
.config/nvim/after/plugin/autopairs.rc.lua
Normal file
7
.config/nvim/after/plugin/autopairs.rc.lua
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
local status, autopairs = pcall(require, "nvim-autopairs")
|
||||
|
||||
if not status then return end
|
||||
|
||||
autopairs.setup({
|
||||
disable_filetype = { "TelescopePrompt", "vim" }
|
||||
})
|
||||
5
.config/nvim/after/plugin/autotags.rc.lua
Normal file
5
.config/nvim/after/plugin/autotags.rc.lua
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
local status, autotag = pcall(require, "nvim-ts-autotag")
|
||||
|
||||
if not status then return end
|
||||
|
||||
autotag.setup()
|
||||
18
.config/nvim/after/plugin/harpoon.rc.lua
Normal file
18
.config/nvim/after/plugin/harpoon.rc.lua
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
local status, mark = pcall(require, "harpoon.mark")
|
||||
|
||||
if not status then return end
|
||||
|
||||
local ui
|
||||
status, ui = pcall(require, "harpoon.ui")
|
||||
|
||||
if not status then return end
|
||||
|
||||
vim.keymap.set("n", "<leader>a", mark.add_file)
|
||||
vim.keymap.set("n", "<C-e>", ui.toggle_quick_menu)
|
||||
|
||||
vim.keymap.set("n", "<leader>q", function() ui.nav_file(1) end)
|
||||
vim.keymap.set("n", "<leader>w", function() ui.nav_file(2) end)
|
||||
vim.keymap.set("n", "<leader>e", function() ui.nav_file(3) end)
|
||||
vim.keymap.set("n", "<leader>r", function() ui.nav_file(4) end)
|
||||
vim.keymap.set("n", "<leader>,", ui.nav_prev)
|
||||
vim.keymap.set("n", "<leader>.", ui.nav_next)
|
||||
|
|
@ -6,7 +6,40 @@ lspzero.preset("recommended")
|
|||
|
||||
-- first argument is the client
|
||||
lspzero.on_attach(function(_, bufnr)
|
||||
lspzero.default_keymaps({buffer = bufnr})
|
||||
lspzero.default_keymaps({ buffer = bufnr })
|
||||
|
||||
-- custom keymaps
|
||||
vim.keymap.set("n", "<leader>f", "<cmd>lua vim.lsp.buf.format()<CR>") -- format buffer
|
||||
end)
|
||||
|
||||
-- Enable format on save
|
||||
lspzero.format_on_save({
|
||||
format_opts = {
|
||||
async = true,
|
||||
timeout_ms = 10000,
|
||||
},
|
||||
servers = {
|
||||
['lua_ls'] = { 'lua' },
|
||||
}
|
||||
})
|
||||
|
||||
local lspconfig
|
||||
status, lspconfig = pcall(require, "lspconfig")
|
||||
|
||||
if status then
|
||||
lspconfig.lua_ls.setup(lspzero.nvim_lua_ls())
|
||||
end
|
||||
|
||||
lspzero.setup()
|
||||
|
||||
local cmp
|
||||
status, cmp = pcall(require, 'cmp')
|
||||
|
||||
if not status then return end
|
||||
|
||||
cmp.setup({
|
||||
mapping = {
|
||||
-- Press "Enter" to confirm completion/suggestion
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||
}
|
||||
})
|
||||
|
|
|
|||
52
.config/nvim/after/plugin/lualine.rc.lua
Normal file
52
.config/nvim/after/plugin/lualine.rc.lua
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
local status, lualine = pcall(require, 'lualine')
|
||||
|
||||
if (not status) then return end
|
||||
|
||||
lualine.setup {
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
section_separators = {
|
||||
left = '',
|
||||
right = ''
|
||||
},
|
||||
component_separators = {
|
||||
left = '',
|
||||
right = ''
|
||||
},
|
||||
disabled_filetypes = {}
|
||||
},
|
||||
sections = {
|
||||
lualine_a = { 'mode' },
|
||||
lualine_b = { 'branch' },
|
||||
lualine_c = { {
|
||||
'filename',
|
||||
file_status = true, -- display file status
|
||||
path = 0 -- no file path
|
||||
} },
|
||||
lualine_x = {
|
||||
{
|
||||
'diagnostics',
|
||||
sources = { 'nvim_diagnostic' },
|
||||
symbols = { error = ' ', warn = ' ', info = ' ', hint = '' }
|
||||
},
|
||||
'enconding',
|
||||
'filetype'
|
||||
},
|
||||
lualine_y = { 'progress' },
|
||||
lualine_z = { 'location' }
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = { {
|
||||
'filename',
|
||||
file_status = true,
|
||||
path = 1
|
||||
} },
|
||||
lualine_x = { 'location' },
|
||||
lualine_y = {},
|
||||
lualine_z = {}
|
||||
},
|
||||
tabline = {},
|
||||
extensions = { 'fugitive' }
|
||||
}
|
||||
63
.config/nvim/after/plugin/telescope.rc.lua
Normal file
63
.config/nvim/after/plugin/telescope.rc.lua
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
local status, telescope = pcall(require, "telescope")
|
||||
|
||||
if not status then return end
|
||||
|
||||
local actions = require("telescope.actions")
|
||||
local builtin = require("telescope.builtin")
|
||||
|
||||
local fb_actions = require "telescope".extensions.file_browser.actions
|
||||
|
||||
local function telescope_buffer_dir()
|
||||
return vim.fn.expand("%:p:h")
|
||||
end
|
||||
|
||||
telescope.setup({
|
||||
defaults = {
|
||||
mappings = {
|
||||
n = {
|
||||
['q'] = actions.close
|
||||
}
|
||||
}
|
||||
},
|
||||
extensions = {
|
||||
file_browser = {
|
||||
theme = "dropdown",
|
||||
hijack_netrw = true,
|
||||
hidden = true,
|
||||
mappings = {
|
||||
['i'] = {
|
||||
['<C-w>'] = function() vim.cmd("normal vbd") end
|
||||
},
|
||||
['n'] = {
|
||||
['N'] = fb_actions.create,
|
||||
['h'] = fb_actions.goto_parent_dir,
|
||||
['/'] = function() vim.cmd("startinsert") end,
|
||||
['D'] = fb_actions.remove
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
telescope.load_extension("file_browser")
|
||||
|
||||
|
||||
-- Set up keymaps specific to telescope
|
||||
vim.keymap.set("n", ";f", function()
|
||||
builtin.find_files({ no_ignore = false, hidden = true })
|
||||
end)
|
||||
vim.keymap.set("n", ";g", builtin.git_files)
|
||||
vim.keymap.set("n", "sf",
|
||||
function()
|
||||
telescope.extensions.file_browser.file_browser({
|
||||
path = "%:p:h",
|
||||
cwd = telescope_buffer_dir(),
|
||||
respect_gitignore = true,
|
||||
hidden = true,
|
||||
grouped = true,
|
||||
previewer = false,
|
||||
initial_mode = "normal",
|
||||
layout_config = { height = 40 }
|
||||
})
|
||||
end)
|
||||
vim.keymap.set("n", ";h", builtin.help_tags)
|
||||
19
.config/nvim/after/plugin/treesitter.rc.lua
Normal file
19
.config/nvim/after/plugin/treesitter.rc.lua
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
local status, treesitter = pcall(require, "nvim-treesitter.configs")
|
||||
|
||||
if not status then return end
|
||||
|
||||
treesitter.setup {
|
||||
-- A list of parser names, or "all"
|
||||
ensure_installed = { "vimdoc", "javascript", "typescript", "c", "lua", "rust" },
|
||||
|
||||
-- Install parsers synchronously (only applied to `ensure_installed`)
|
||||
sync_install = false,
|
||||
|
||||
-- Automatically install missing parsers when entering buffer
|
||||
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
|
||||
auto_install = true,
|
||||
|
||||
highlight = {
|
||||
enable = true,
|
||||
},
|
||||
}
|
||||
16
.config/nvim/after/plugin/undotree.rc.lua
Normal file
16
.config/nvim/after/plugin/undotree.rc.lua
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
vim.keymap.set("n", "<leader>u", vim.cmd.UndotreeToggle)
|
||||
|
||||
local has_persistent_undo = vim.api.nvim_call_function("has", { "persistent_undo" })
|
||||
|
||||
if has_persistent_undo then
|
||||
local target_path = vim.api.nvim_call_function("expand", { "~/.undodir" })
|
||||
|
||||
local is_directory = vim.api.nvim_call_function("isdirectory", { target_path })
|
||||
|
||||
if not is_directory then
|
||||
vim.api.nvim_call_function("mkdir", { target_path, "p", 0700 })
|
||||
end
|
||||
|
||||
vim.opt.undodir = target_path
|
||||
vim.opt.undofile = true
|
||||
end
|
||||
|
|
@ -1,5 +1,10 @@
|
|||
vim.g.mapleader = " "
|
||||
|
||||
-- easy escape
|
||||
vim.keymap.set("i", "<C-[>", "<Esc>", { noremap = true, silent = true })
|
||||
vim.keymap.set("v", "<C-[>", "<Esc>", { noremap = true, silent = true })
|
||||
vim.keymap.set("n", "<C-[>", "<Esc>", { noremap = true, silent = true })
|
||||
|
||||
-- open the explorer
|
||||
vim.keymap.set("n", "<leader>e", "<cmd>Ex<CR>")
|
||||
|
||||
|
|
@ -21,8 +26,10 @@ vim.keymap.set("n", "N", "Nzzzv")
|
|||
-- do not copy with x, for god sake, WHY copy something that is being deleted??
|
||||
vim.keymap.set("n", "x", "\"_x")
|
||||
|
||||
-- smile
|
||||
-- smile :)
|
||||
vim.keymap.set("n", "Q", "<nop>")
|
||||
vim.keymap.set("n", "q", "<nop>", { noremap = true })
|
||||
vim.keymap.set("n", "<leader>q", "q", { noremap = true })
|
||||
|
||||
-- select and replace
|
||||
vim.keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
|
||||
|
|
@ -32,8 +39,8 @@ vim.keymap.set("n", "dd", "\"_dd")
|
|||
vim.keymap.set("n", "<leader>dd", "dd") -- cut line, under my control
|
||||
|
||||
-- copy/paste to/from system clipboard
|
||||
vim.keymap.set({"n", "v"}, "<leader>y", "\"+y")
|
||||
vim.keymap.set({"n", "v"}, "<leader>p", "\"+p")
|
||||
vim.keymap.set({ "n", "v" }, "<leader>y", "\"+y")
|
||||
vim.keymap.set({ "n", "v" }, "<leader>p", "\"+p")
|
||||
|
||||
-- increment/decrement a count, helpful for changing indeces
|
||||
vim.keymap.set("n", "+", "<C-a>")
|
||||
|
|
@ -66,3 +73,17 @@ vim.keymap.set("n", "<C-w><left>", "<C-w><")
|
|||
vim.keymap.set("n", "<C-w><right>", "<C-w>>")
|
||||
vim.keymap.set("n", "<C-w><up>", "<C-w>+")
|
||||
vim.keymap.set("n", "<C-w><down>", "<C-w>-")
|
||||
|
||||
-- my arrow keys babyyyy
|
||||
vim.keymap.set("i", "<C-h>", "<Left>", { noremap = true })
|
||||
vim.keymap.set("i", "<C-j>", "<Down>", { noremap = true })
|
||||
vim.keymap.set("i", "<C-k>", "<Up>", { noremap = true })
|
||||
vim.keymap.set("i", "<C-l>", "<Right>", { noremap = true })
|
||||
|
||||
-- terminal keymaps
|
||||
vim.keymap.set("t", "<C-t>", "<C-\\><C-n>", { noremap = true })
|
||||
vim.keymap.set("t", "<C-x>", "<cmd>bd!<CR>", { noremap = true })
|
||||
vim.keymap.set("n", "<C-t>", "<cmd>term<CR>i", { noremap = true })
|
||||
|
||||
-- lazygit on floaterm
|
||||
vim.keymap.set("n", "<leader>g", "<cmd>FloatermNew lazygit<CR>", { noremap = true })
|
||||
|
|
|
|||
|
|
@ -14,19 +14,55 @@ return require('packer').startup(function(use)
|
|||
branch = 'v2.x',
|
||||
requires = {
|
||||
-- LSP Support
|
||||
{'neovim/nvim-lspconfig'}, -- Required
|
||||
{ 'neovim/nvim-lspconfig' }, -- Required
|
||||
{ -- Optional
|
||||
'williamboman/mason.nvim',
|
||||
run = function()
|
||||
pcall(vim.cmd, 'MasonUpdate')
|
||||
end,
|
||||
},
|
||||
{'williamboman/mason-lspconfig.nvim'}, -- Optional
|
||||
{ 'williamboman/mason-lspconfig.nvim' }, -- Optional
|
||||
|
||||
-- Autocompletion
|
||||
{'hrsh7th/nvim-cmp'}, -- Required
|
||||
{'hrsh7th/cmp-nvim-lsp'}, -- Required
|
||||
{'L3MON4D3/LuaSnip'}, -- Required
|
||||
{ 'hrsh7th/nvim-cmp' }, -- Required
|
||||
{ 'hrsh7th/cmp-nvim-lsp' }, -- Required
|
||||
{ 'L3MON4D3/LuaSnip' }, -- Required
|
||||
}
|
||||
}
|
||||
|
||||
-- Telescope for the fine file navigation
|
||||
use {
|
||||
'nvim-telescope/telescope.nvim', tag = '0.1.2',
|
||||
requires = { { 'nvim-lua/plenary.nvim' } }
|
||||
}
|
||||
|
||||
use {
|
||||
"nvim-telescope/telescope-file-browser.nvim",
|
||||
requires = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" }
|
||||
}
|
||||
|
||||
use('nvim-treesitter/nvim-treesitter', { run = ':TSUpdate' })
|
||||
|
||||
use {
|
||||
'nvim-lualine/lualine.nvim',
|
||||
requires = { 'nvim-tree/nvim-web-devicons', opt = true }
|
||||
}
|
||||
|
||||
-- autopairs, complete brackets
|
||||
use {
|
||||
"windwp/nvim-autopairs",
|
||||
config = function() require("nvim-autopairs").setup {} end
|
||||
}
|
||||
|
||||
-- auto closing tags
|
||||
use "windwp/nvim-ts-autotag"
|
||||
|
||||
-- quick navigation between files, harpoon
|
||||
use 'ThePrimeagen/harpoon'
|
||||
|
||||
-- shows a history to undo
|
||||
use 'mbbill/undotree'
|
||||
|
||||
-- float window for terminal commands
|
||||
use 'voldikss/vim-floaterm'
|
||||
end)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue