Add floating terminal to nvim config
This commit is contained in:
parent
cc13e44e9f
commit
5e80781558
@ -1,5 +1,6 @@
|
|||||||
require('core.config')
|
require("core.config")
|
||||||
vim.opt.runtimepath:prepend(vim.fn.stdpath('data') .. '/lazy/lazy.nvim')
|
require("core.keymaps")
|
||||||
require('lazy').setup('plugins', {
|
vim.opt.runtimepath:prepend(vim.fn.stdpath("data") .. "/lazy/lazy.nvim")
|
||||||
|
require("lazy").setup("plugins", {
|
||||||
version = "*",
|
version = "*",
|
||||||
})
|
})
|
||||||
|
|||||||
16
dot_config/nvim/lua/core/commands.lua
Normal file
16
dot_config/nvim/lua/core/commands.lua
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
vim.api.nvim_create_user_command("W", "write", {})
|
||||||
|
vim.api.nvim_create_user_command("Q", "qall!", {})
|
||||||
|
|
||||||
|
-- Create a floating terminal
|
||||||
|
vim.api.nvim_create_user_command("FloaTerm", require("core.lib.toggle_terminal"), {
|
||||||
|
desc = "Toggle a floating terminal",
|
||||||
|
})
|
||||||
|
|
||||||
|
-- highlight text on copy
|
||||||
|
vim.api.nvim_create_autocmd("TextYankPost", {
|
||||||
|
desc = "Highlight when yanking (copying) text",
|
||||||
|
callback = vim.highlight.on_yank,
|
||||||
|
group = vim.api.nvim_create_augroup("kickstart-highlight-yank", {
|
||||||
|
clear = true,
|
||||||
|
}),
|
||||||
|
})
|
||||||
@ -1,16 +1,15 @@
|
|||||||
vim.g.mapleader = ','
|
vim.g.mapleader = ","
|
||||||
vim.g.maplocalleader = ','
|
vim.g.maplocalleader = ","
|
||||||
|
|
||||||
vim.opt.fileformats = { 'unix', 'dos', 'mac' }
|
vim.opt.fileformats = { "unix", "dos", "mac" }
|
||||||
|
|
||||||
vim.opt.mouse = 'a'
|
vim.opt.mouse = "a"
|
||||||
vim.opt.clipboard = 'unnamedplus'
|
vim.opt.clipboard = "unnamedplus"
|
||||||
vim.opt.breakindent = true
|
vim.opt.breakindent = true
|
||||||
vim.opt.undofile = true
|
vim.opt.undofile = true
|
||||||
vim.opt.signcolumn = 'yes'
|
|
||||||
|
|
||||||
vim.opt.updatetime = 250
|
vim.opt.updatetime = 250
|
||||||
vim.opt.timeoutlen = 300
|
vim.opt.timeoutlen = 1000
|
||||||
|
|
||||||
vim.opt.splitright = true
|
vim.opt.splitright = true
|
||||||
vim.opt.splitbelow = true
|
vim.opt.splitbelow = true
|
||||||
@ -29,8 +28,8 @@ vim.opt.number = true
|
|||||||
vim.opt.numberwidth = 4
|
vim.opt.numberwidth = 4
|
||||||
vim.opt.relativenumber = true
|
vim.opt.relativenumber = true
|
||||||
vim.opt.showmatch = true
|
vim.opt.showmatch = true
|
||||||
vim.opt.spelllang = 'en_us'
|
vim.opt.spelllang = "en_us"
|
||||||
vim.opt.wildmode = 'list:longest'
|
vim.opt.wildmode = "list:longest"
|
||||||
vim.opt.cursorline = true
|
vim.opt.cursorline = true
|
||||||
|
|
||||||
-- Indent
|
-- Indent
|
||||||
@ -42,41 +41,13 @@ vim.opt.shiftround = true
|
|||||||
-- Text Formatting/Layout
|
-- Text Formatting/Layout
|
||||||
vim.opt.ignorecase = true
|
vim.opt.ignorecase = true
|
||||||
vim.opt.list = true
|
vim.opt.list = true
|
||||||
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' }
|
vim.opt.listchars = { tab = "» ", trail = "·", nbsp = "␣" }
|
||||||
vim.opt.inccommand = 'split'
|
vim.opt.inccommand = "split"
|
||||||
vim.opt.smartcase = true
|
vim.opt.smartcase = true
|
||||||
vim.opt.wrap = false
|
vim.opt.wrap = false
|
||||||
vim.opt.whichwrap:append {
|
vim.opt.whichwrap:append {
|
||||||
['<'] = true,
|
["<"] = true,
|
||||||
['>'] = true,
|
[">"] = true,
|
||||||
['['] = true,
|
["["] = true,
|
||||||
[']'] = true,
|
["]"] = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
vim.api.nvim_create_user_command('W', 'write', {})
|
|
||||||
vim.api.nvim_create_user_command('Q', 'qall!', {})
|
|
||||||
|
|
||||||
vim.keymap.set('n', '<leader>l', ':nohlsearch<CR>', { desc = 'clear highlighted search' })
|
|
||||||
vim.keymap.set('n', '<leader>ts', [[:%s/\s\s*$//g<CR>]], { desc = '[T]rim trailing [S]pace' })
|
|
||||||
vim.keymap.set('n', '<leader>ss', ':setlocal spell!<CR>', { desc = '[S]et [S]pell' })
|
|
||||||
vim.keymap.set('n', '<leader>p', ':set paste!<CR>', { desc = '[P]aste' })
|
|
||||||
vim.keymap.set('n', '<leader>nn', ':set nonumber norelativenumber<CR>', { desc = '[N]o [N]umber removed number and relative number' })
|
|
||||||
vim.keymap.set('n', '<leader>rn', ':set number relativenumber<CR>', { desc = '[R]elative [N]umber - set relative number and absolute number' })
|
|
||||||
|
|
||||||
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 diagnopstic [Q]uickfix list' })
|
|
||||||
|
|
||||||
-- Use <Ctrl-h/j/k/l> to move between windows, no need for <Ctrl-w> first
|
|
||||||
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus up window' })
|
|
||||||
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus down window' })
|
|
||||||
vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus left window' })
|
|
||||||
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus right window' })
|
|
||||||
|
|
||||||
-- highlight text on copy
|
|
||||||
vim.api.nvim_create_autocmd('TextYankPost', {
|
|
||||||
desc = 'Highlight when yanking (copying) text',
|
|
||||||
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
|
|
||||||
callback = vim.highlight.on_yank,
|
|
||||||
})
|
|
||||||
|
|||||||
23
dot_config/nvim/lua/core/keymaps.lua
Normal file
23
dot_config/nvim/lua/core/keymaps.lua
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
require("core.commands")
|
||||||
|
local toggle_terminal = require("core.lib.toggle_terminal")
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>l", ":nohlsearch<CR>", { desc = "clear highlighted search" })
|
||||||
|
vim.keymap.set("n", "<leader>ts", [[:%s/\s\s*$//g<CR>]], { desc = "[T]rim trailing [S]pace" })
|
||||||
|
vim.keymap.set("n", "<leader>ss", ":setlocal spell!<CR>", { desc = "[S]et [S]pell" })
|
||||||
|
vim.keymap.set("n", "<leader>p", ":set paste!<CR>", { desc = "[P]aste" })
|
||||||
|
vim.keymap.set("n", "<leader>nn", ":set nonumber norelativenumber<CR>", { desc = "[N]o [N]umber removed number and relative number" })
|
||||||
|
vim.keymap.set("n", "<leader>rn", ":set number relativenumber<CR>", { desc = "[R]elative [N]umber - set relative number and absolute number" })
|
||||||
|
|
||||||
|
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 diagnopstic [Q]uickfix list" })
|
||||||
|
|
||||||
|
-- Use <Ctrl-h/j/k/l> to move between windows, no need for <Ctrl-w> first
|
||||||
|
vim.keymap.set("n", "<C-j>", "<C-w><C-j>", { desc = "Move focus up window" })
|
||||||
|
vim.keymap.set("n", "<C-k>", "<C-w><C-k>", { desc = "Move focus down window" })
|
||||||
|
vim.keymap.set("n", "<C-h>", "<C-w><C-h>", { desc = "Move focus left window" })
|
||||||
|
vim.keymap.set("n", "<C-l>", "<C-w><C-l>", { desc = "Move focus right window" })
|
||||||
|
|
||||||
|
vim.keymap.set({ "n", "t" }, "<leader>tt", toggle_terminal)
|
||||||
|
vim.keymap.set("t", "<esc><esc>", "<c-\\><c-n>")
|
||||||
25
dot_config/nvim/lua/core/lib/find_git_root.lua
Normal file
25
dot_config/nvim/lua/core/lib/find_git_root.lua
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
-- Telescope live_grep in git root
|
||||||
|
-- Function to find the git root directory based on the current buffer's path
|
||||||
|
local function find_git_root()
|
||||||
|
-- Use the current buffer's path as the starting point for the git search
|
||||||
|
local current_file = vim.api.nvim_buf_get_name(0)
|
||||||
|
local current_dir
|
||||||
|
local cwd = vim.fn.getcwd()
|
||||||
|
-- If the buffer is not associated with a file, return nil
|
||||||
|
if current_file == '' then
|
||||||
|
current_dir = cwd
|
||||||
|
else
|
||||||
|
-- Extract the directory from the current file's path
|
||||||
|
current_dir = vim.fn.fnamemodify(current_file, ':h')
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Find the Git root directory from the current file's path
|
||||||
|
local git_root = vim.fn.systemlist('git -C ' .. vim.fn.escape(current_dir, ' ') .. ' rev-parse --show-toplevel')[1]
|
||||||
|
if vim.v.shell_error ~= 0 then
|
||||||
|
print('Not a git repository. Searching on current working directory')
|
||||||
|
return cwd
|
||||||
|
end
|
||||||
|
return git_root
|
||||||
|
end
|
||||||
|
|
||||||
|
return find_git_root
|
||||||
45
dot_config/nvim/lua/core/lib/toggle_terminal.lua
Normal file
45
dot_config/nvim/lua/core/lib/toggle_terminal.lua
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
local state = {
|
||||||
|
floating = {
|
||||||
|
buf = -1,
|
||||||
|
win = -1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
local function create_floating_window(ops)
|
||||||
|
ops = ops or {}
|
||||||
|
local width = ops.width or math.floor(vim.o.columns * 0.8)
|
||||||
|
local height = ops.height or math.floor(vim.o.lines * 0.8)
|
||||||
|
|
||||||
|
local buf
|
||||||
|
if vim.api.nvim_buf_is_valid(state.floating.buf) then
|
||||||
|
buf = state.floating.buf
|
||||||
|
vim.cmd("startinsert")
|
||||||
|
else
|
||||||
|
buf = vim.api.nvim_create_buf(false, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
local win = vim.api.nvim_open_win(buf, true, {
|
||||||
|
relative = "editor",
|
||||||
|
style = "minimal",
|
||||||
|
border = "rounded",
|
||||||
|
width = width,
|
||||||
|
height = height,
|
||||||
|
col = math.floor((vim.o.columns - width) / 2),
|
||||||
|
row = math.floor((vim.o.lines - height) / 2),
|
||||||
|
})
|
||||||
|
return { buf = buf, win = win }
|
||||||
|
end
|
||||||
|
|
||||||
|
local function toggle_terminal()
|
||||||
|
if vim.api.nvim_win_is_valid(state.floating.win) then
|
||||||
|
vim.api.nvim_win_hide(state.floating.win)
|
||||||
|
else
|
||||||
|
state.floating = create_floating_window { buf = state.floating.buf }
|
||||||
|
if vim.bo[state.floating.buf].buftype ~= "terminal" then
|
||||||
|
vim.cmd.terminal()
|
||||||
|
vim.cmd("startinsert")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return toggle_terminal
|
||||||
@ -1,14 +1,14 @@
|
|||||||
local M = { 'hrsh7th/nvim-cmp' }
|
local M = { "hrsh7th/nvim-cmp" }
|
||||||
|
|
||||||
M.name = 'cmp'
|
M.name = "cmp"
|
||||||
M.dependencies = {
|
M.dependencies = {
|
||||||
'saadparwaiz1/cmp_luasnip',
|
"saadparwaiz1/cmp_luasnip",
|
||||||
'hrsh7th/cmp-nvim-lsp',
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
}
|
}
|
||||||
|
|
||||||
function M.config()
|
function M.config()
|
||||||
local cmp = require 'cmp'
|
local cmp = require "cmp"
|
||||||
local luasnip = require 'luasnip'
|
local luasnip = require "luasnip"
|
||||||
|
|
||||||
local function expand(args)
|
local function expand(args)
|
||||||
luasnip.lsp_expand(args.body)
|
luasnip.lsp_expand(args.body)
|
||||||
@ -39,19 +39,19 @@ function M.config()
|
|||||||
|
|
||||||
snippet = { expand = expand },
|
snippet = { expand = expand },
|
||||||
sources = {
|
sources = {
|
||||||
{ name = 'nvim_lsp' },
|
{ name = "nvim_lsp" },
|
||||||
{ name = 'luasnip' },
|
{ name = "luasnip" },
|
||||||
},
|
},
|
||||||
|
|
||||||
mapping = cmp.mapping.preset.insert {
|
mapping = cmp.mapping.preset.insert {
|
||||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
["<C-n>"] = cmp.mapping.select_next_item(),
|
||||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
["<C-p>"] = cmp.mapping.select_prev_item(),
|
||||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||||
['<C-Space>'] = cmp.mapping.complete({}),
|
["<C-Space>"] = cmp.mapping.complete({}),
|
||||||
['<Tab>'] = cmp.mapping(tab_mapping, { 'i', 's' }),
|
["<Tab>"] = cmp.mapping(tab_mapping, { "i", "s" }),
|
||||||
['<S-Tab>'] = cmp.mapping(back_tab_mapping, { 'i', 's' }),
|
["<S-Tab>"] = cmp.mapping(back_tab_mapping, { "i", "s" }),
|
||||||
['<CR>'] = cmp.mapping.confirm {
|
["<CR>"] = cmp.mapping.confirm {
|
||||||
behavior = cmp.ConfirmBehavior.Replace,
|
behavior = cmp.ConfirmBehavior.Replace,
|
||||||
select = true,
|
select = true,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,18 +1,17 @@
|
|||||||
-- https://github.com/tpope/vim-surround
|
-- https://github.com/tpope/vim-surround
|
||||||
-- surround.vim: Delete/change/add parentheses/quotes/XML-tags/much more with ease
|
-- surround.vim: Delete/change/add parentheses/quotes/XML-tags/much more with ease
|
||||||
local M = { 'tpope/vim-surround' }
|
local M = { "tpope/vim-surround" }
|
||||||
|
|
||||||
M.tag = 'v2.2'
|
M.tag = "v2.2"
|
||||||
M.dependencies = {
|
M.dependencies = {
|
||||||
-- https://github.com/tpope/vim-sleuth
|
-- https://github.com/tpope/vim-sleuth
|
||||||
-- sleuth.vim: Heuristically set buffer options
|
-- sleuth.vim: Heuristically set buffer options
|
||||||
{ 'tpope/vim-sleuth', tag = 'v2.0' },
|
{ "tpope/vim-sleuth", tag = "v2.0" },
|
||||||
|
|
||||||
-- https://github.com/numToStr/Comment.nvim
|
-- https://github.com/numToStr/Comment.nvim
|
||||||
-- 🧠 💪 // Smart and powerful comment plugin for neovim.
|
-- 🧠 💪 // Smart and powerful comment plugin for neovim.
|
||||||
-- Supports treesitter, dot repeat, left-right/up-down motions, hooks, and more
|
-- Supports treesitter, dot repeat, left-right/up-down motions, hooks, and more
|
||||||
{ 'numToStr/Comment.nvim', opts = {}, lazy = false },
|
{ "numToStr/Comment.nvim", opts = {}, lazy = false },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
@ -1,17 +1,16 @@
|
|||||||
-- https://github.com/ray-x/go.nvim
|
-- https://github.com/ray-x/go.nvim
|
||||||
-- A modern go neovim plugin based on treesitter, nvim-lsp and dap debugger.
|
-- A modern go neovim plugin based on treesitter, nvim-lsp and dap debugger.
|
||||||
local M = { 'ray-x/go.nvim' }
|
local M = { "ray-x/go.nvim" }
|
||||||
|
|
||||||
M.name = 'go'
|
M.name = "go"
|
||||||
M.event = { 'CmdlineEnter' }
|
M.event = { "CmdlineEnter" }
|
||||||
M.ft = { 'go', 'gomod' }
|
M.ft = { "go", "gomod" }
|
||||||
M.dependencies = {
|
M.dependencies = {
|
||||||
-- https://github.com/ray-x/guihua.lua
|
-- https://github.com/ray-x/guihua.lua
|
||||||
-- Guihua: A Lua Gui and util library for nvim plugins
|
-- Guihua: A Lua Gui and util library for nvim plugins
|
||||||
'ray-x/guihua.lua',
|
"ray-x/guihua.lua",
|
||||||
|
"lspconfig",
|
||||||
'lspconfig',
|
"treesitter",
|
||||||
'treesitter',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function M.config()
|
function M.config()
|
||||||
|
|||||||
@ -1,32 +1,31 @@
|
|||||||
# chezmoi:template:left-delimiter=--{{
|
# chezmoi:template:left-delimiter=--{{
|
||||||
--{{- /* vim: set filetype=lua: */ -}}
|
--{{- /* vim: set filetype=lua: */ -}}
|
||||||
local M = { 'neovim/nvim-lspconfig' }
|
local M = { "neovim/nvim-lspconfig" }
|
||||||
|
|
||||||
M.name = 'lspconfig'
|
M.name = "lspconfig"
|
||||||
M.tag = 'v1.0.0'
|
M.tag = "v1.0.0"
|
||||||
|
|
||||||
M.dependencies = {
|
M.dependencies = {
|
||||||
{ 'j-hui/fidget.nvim', tag = 'legacy', opts = {} },
|
{ "j-hui/fidget.nvim", tag = "legacy", opts = {} },
|
||||||
{ 'folke/trouble.nvim', tag = 'v3.6.0' },
|
{ "folke/trouble.nvim", tag = "v3.6.0" },
|
||||||
{ 'folke/lazydev.nvim', tag = 'v1.9.0', ft = "lua", opts = {} },
|
{ "folke/lazydev.nvim", tag = "v1.9.0", ft = "lua", opts = {} },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
local function format_buffer(_)
|
local function format_buffer(_)
|
||||||
vim.lsp.buf.format()
|
vim.lsp.buf.format()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function on_attach(_, buffer)
|
local function on_attach(_, buffer)
|
||||||
-- Create a command `:Format` local to the LSP buffer
|
-- Create a command `:Format` local to the LSP buffer
|
||||||
vim.api.nvim_buf_create_user_command(buffer, 'Format', format_buffer, {
|
vim.api.nvim_buf_create_user_command(buffer, "Format", format_buffer, {
|
||||||
desc = 'Format current buffer with LSP',
|
desc = "Format current buffer with LSP",
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.config()
|
function M.config()
|
||||||
local lspconfig = require('lspconfig')
|
local lspconfig = require("lspconfig")
|
||||||
|
|
||||||
local capabilities = require('cmp_nvim_lsp').default_capabilities(
|
local capabilities = require("cmp_nvim_lsp").default_capabilities(
|
||||||
vim.lsp.protocol.make_client_capabilities())
|
vim.lsp.protocol.make_client_capabilities())
|
||||||
|
|
||||||
--{{ if lookPath "bash-language-server" -}}
|
--{{ if lookPath "bash-language-server" -}}
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
-- https://github.com/L3MON4D3/LuaSnip
|
-- https://github.com/L3MON4D3/LuaSnip
|
||||||
-- Snippet Engine for Neovim written in Lua.
|
-- Snippet Engine for Neovim written in Lua.
|
||||||
local M = { 'L3MON4D3/LuaSnip' }
|
local M = { "L3MON4D3/LuaSnip" }
|
||||||
|
|
||||||
M.tag = 'v2.3.0'
|
M.tag = "v2.3.0"
|
||||||
M.dependencies = {}
|
M.dependencies = {}
|
||||||
|
|
||||||
function M.config()
|
function M.config()
|
||||||
local luasnip = require 'luasnip'
|
local luasnip = require "luasnip"
|
||||||
luasnip.setup()
|
luasnip.setup()
|
||||||
luasnip.config.setup({})
|
luasnip.config.setup({})
|
||||||
require("luasnip.loaders.from_snipmate").lazy_load()
|
require("luasnip.loaders.from_snipmate").lazy_load()
|
||||||
|
|||||||
@ -1,40 +1,37 @@
|
|||||||
local lib = require('core.lib')
|
local find_git_root = require("core.lib.find_git_root")
|
||||||
local M = { 'nvim-telescope/telescope.nvim' }
|
local M = { "nvim-telescope/telescope.nvim" }
|
||||||
|
|
||||||
M.branch = '0.1.x'
|
M.branch = "0.1.x"
|
||||||
M.event = 'VimEnter'
|
M.event = "VimEnter"
|
||||||
M.dependencies = {
|
M.dependencies = {
|
||||||
'nvim-lua/plenary.nvim',
|
"nvim-lua/plenary.nvim",
|
||||||
{
|
"nvim-telescope/telescope-ui-select.nvim",
|
||||||
'nvim-telescope/telescope-fzf-native.nvim',
|
"nvim-tree/nvim-web-devicons",
|
||||||
build = 'make',
|
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
|
||||||
},
|
|
||||||
'nvim-telescope/telescope-ui-select.nvim',
|
|
||||||
'nvim-tree/nvim-web-devicons',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Custom live_grep function to search in git root
|
-- Custom live_grep function to search in git root
|
||||||
local function live_grep_git_root()
|
local function live_grep_git_root()
|
||||||
local git_root = lib.find_git_root()
|
local git_root = find_git_root()
|
||||||
if git_root then
|
if git_root then
|
||||||
require('telescope.builtin').live_grep({
|
require("telescope.builtin").live_grep({
|
||||||
search_dirs = { git_root },
|
search_dirs = { git_root },
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {})
|
vim.api.nvim_create_user_command("LiveGrepGitRoot", live_grep_git_root, {})
|
||||||
|
|
||||||
function M.config()
|
function M.config()
|
||||||
-- See `:help telescope` and `:help telescope.setup()`
|
-- See `:help telescope` and `:help telescope.setup()`
|
||||||
local telescope = require('telescope')
|
local telescope = require("telescope")
|
||||||
local builtin = require('telescope.builtin')
|
local builtin = require("telescope.builtin")
|
||||||
local themes = require('telescope.themes')
|
local themes = require("telescope.themes")
|
||||||
|
|
||||||
telescope.setup({
|
telescope.setup({
|
||||||
-- pickers = {}
|
-- pickers = {}
|
||||||
extensions = {
|
extensions = {
|
||||||
['ui-select'] = {
|
["ui-select"] = {
|
||||||
themes.get_dropdown(),
|
themes.get_dropdown(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -42,17 +39,17 @@ function M.config()
|
|||||||
defaults = {
|
defaults = {
|
||||||
mappings = {
|
mappings = {
|
||||||
i = {
|
i = {
|
||||||
['<C-u>'] = false,
|
["<C-u>"] = false,
|
||||||
['<C-d>'] = false,
|
["<C-d>"] = false,
|
||||||
['<C-enter>'] = 'to_fuzzy_refine',
|
["<C-enter>"] = "to_fuzzy_refine",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Enable telescope fzf native, if installed
|
-- Enable telescope fzf native, if installed
|
||||||
pcall(telescope.load_extension, 'fzf')
|
pcall(telescope.load_extension, "fzf")
|
||||||
pcall(telescope.load_extension, 'ui-select')
|
pcall(telescope.load_extension, "ui-select")
|
||||||
|
|
||||||
local function fuzzy_find()
|
local function fuzzy_find()
|
||||||
-- You can pass additional configuration to telescope to change theme,
|
-- You can pass additional configuration to telescope to change theme,
|
||||||
@ -64,19 +61,19 @@ function M.config()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- See `:help telescope.builtin`
|
-- See `:help telescope.builtin`
|
||||||
vim.keymap.set('n', '<leader>sh', builtin.help_tags, { desc = '[S]earch [H]elp' })
|
vim.keymap.set("n", "<leader>sh", builtin.help_tags, { desc = "[S]earch [H]elp" })
|
||||||
vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' })
|
vim.keymap.set("n", "<leader>sk", builtin.keymaps, { desc = "[S]earch [K]eymaps" })
|
||||||
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' })
|
vim.keymap.set("n", "<leader>sf", builtin.find_files, { desc = "[S]earch [F]iles" })
|
||||||
vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' })
|
vim.keymap.set("n", "<leader>ss", builtin.builtin, { desc = "[S]earch [S]elect Telescope" })
|
||||||
vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
|
vim.keymap.set("n", "<leader>sw", builtin.grep_string, { desc = "[S]earch current [W]ord" })
|
||||||
vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
|
vim.keymap.set("n", "<leader>sg", builtin.live_grep, { desc = "[S]earch by [G]rep" })
|
||||||
vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
|
vim.keymap.set("n", "<leader>sd", builtin.diagnostics, { desc = "[S]earch [D]iagnostics" })
|
||||||
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
|
vim.keymap.set("n", "<leader>sr", builtin.resume, { desc = "[S]earch [R]esume" })
|
||||||
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
|
vim.keymap.set("n", "<leader>s.", builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
|
||||||
vim.keymap.set('n', '<leader>sG', live_grep_git_root, { desc = '[S]earch by [G]rep on Git Root' })
|
vim.keymap.set("n", "<leader>sG", live_grep_git_root, { desc = "[S]earch by [G]rep on Git Root" })
|
||||||
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
|
vim.keymap.set("n", "<leader><leader>", builtin.buffers, { desc = "[ ] Find existing buffers" })
|
||||||
vim.keymap.set('n', '<leader>/', fuzzy_find, { desc = '[/] Fuzzily search in current buffer' })
|
vim.keymap.set("n", "<leader>/", fuzzy_find, { desc = "[/] Fuzzily search in current buffer" })
|
||||||
vim.keymap.set('n', '<leader>gf', builtin.git_files, { desc = 'Search [G]it [F]iles' })
|
vim.keymap.set("n", "<leader>gf", builtin.git_files, { desc = "Search [G]it [F]iles" })
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
@ -1,27 +1,27 @@
|
|||||||
-- https://github.com/morhetz/gruvbox
|
-- https://github.com/morhetz/gruvbox
|
||||||
local M = { 'morhetz/gruvbox' }
|
local M = { "morhetz/gruvbox" }
|
||||||
|
|
||||||
M.priority = 1000
|
M.priority = 1000
|
||||||
M.dependencies = {
|
M.dependencies = {
|
||||||
-- https://github.com/nvim-lualine/lualine.nvim
|
-- https://github.com/nvim-lualine/lualine.nvim
|
||||||
'nvim-lualine/lualine.nvim',
|
"nvim-lualine/lualine.nvim",
|
||||||
opts = {
|
opts = {
|
||||||
options = {
|
options = {
|
||||||
theme = 'gruvbox',
|
theme = "gruvbox",
|
||||||
},
|
},
|
||||||
sections = {
|
sections = {
|
||||||
lualine_a = { 'mode' },
|
lualine_a = { "mode" },
|
||||||
lualine_b = { 'diagnostics' },
|
lualine_b = { "diagnostics" },
|
||||||
lualine_c = { { 'filename', path = 3 } },
|
lualine_c = { { "filename", path = 3 } },
|
||||||
lualine_x = { 'encoding', 'fileformat', 'filetype' },
|
lualine_x = { "encoding", "fileformat", "filetype" },
|
||||||
lualine_y = { 'progress' },
|
lualine_y = { "progress" },
|
||||||
lualine_z = { 'location' }
|
lualine_z = { "location" }
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
function M.config()
|
function M.config()
|
||||||
vim.cmd.colorscheme 'gruvbox'
|
vim.cmd.colorscheme("gruvbox")
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
@ -2,25 +2,25 @@ vim.g.loaded_netrw = 1
|
|||||||
vim.g.loaded_netrwPlugin = 1
|
vim.g.loaded_netrwPlugin = 1
|
||||||
vim.opt.termguicolors = true
|
vim.opt.termguicolors = true
|
||||||
|
|
||||||
local M = { 'nvim-tree/nvim-tree.lua' }
|
local M = { "nvim-tree/nvim-tree.lua" }
|
||||||
|
|
||||||
M.tag = 'nvim-tree-v1.9.0'
|
M.tag = "nvim-tree-v1.9.0"
|
||||||
|
|
||||||
M.keys = {
|
M.keys = {
|
||||||
{ '<leader>nt', ':NvimTreeToggle<CR>', desc = 'toggle nvim tree' }
|
{ "<leader>nt", ":NvimTreeToggle<CR>", desc = "toggle nvim tree" }
|
||||||
}
|
}
|
||||||
|
|
||||||
M.dependencies = {
|
M.dependencies = {
|
||||||
-- https://github.com/nvim-tree/nvim-web-devicons
|
-- https://github.com/nvim-tree/nvim-web-devicons
|
||||||
'nvim-tree/nvim-web-devicons', opts = {}
|
"nvim-tree/nvim-web-devicons", opts = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
function M.config()
|
function M.config()
|
||||||
require('nvim-tree').setup()
|
require("nvim-tree").setup()
|
||||||
vim.api.nvim_create_autocmd('WinClosed', {
|
vim.api.nvim_create_autocmd("WinClosed", {
|
||||||
nested = true,
|
nested = true,
|
||||||
callback = function()
|
callback = function()
|
||||||
M.handle_closed(tonumber(vim.fn.expand('<amatch>')))
|
M.handle_closed(tonumber(vim.fn.expand("<amatch>")))
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
@ -37,9 +37,9 @@ function M.handle_closed(window)
|
|||||||
local windows = vim.tbl_filter(filter_window, vim.api.nvim_tabpage_list_wins(tab))
|
local windows = vim.tbl_filter(filter_window, vim.api.nvim_tabpage_list_wins(tab))
|
||||||
local buffers = vim.tbl_map(vim.api.nvim_win_get_buf, windows)
|
local buffers = vim.tbl_map(vim.api.nvim_win_get_buf, windows)
|
||||||
|
|
||||||
if info.name:match('.*NvimTree_%d*$') then
|
if info.name:match(".*NvimTree_%d*$") then
|
||||||
if not vim.tbl_isempty(buffers) then
|
if not vim.tbl_isempty(buffers) then
|
||||||
require('nvim-tree.api').tree.close()
|
require("nvim-tree.api").tree.close()
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -49,10 +49,10 @@ function M.handle_closed(window)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local last_info = vim.fn.getbufinfo(buffers[1])[1]
|
local last_info = vim.fn.getbufinfo(buffers[1])[1]
|
||||||
if last_info.name:match('.*NvimTree_%d*$') then
|
if last_info.name:match(".*NvimTree_%d*$") then
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
if #vim.api.nvim_list_wins() == 1 then
|
if #vim.api.nvim_list_wins() == 1 then
|
||||||
vim.cmd 'quit'
|
vim.cmd "quit"
|
||||||
else
|
else
|
||||||
vim.api.nvim_win_close(windows[1], true)
|
vim.api.nvim_win_close(windows[1], true)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
local M = {'nvim-treesitter/nvim-treesitter' }
|
local M = {"nvim-treesitter/nvim-treesitter" }
|
||||||
|
|
||||||
M.name = 'treesitter'
|
M.name = "treesitter"
|
||||||
M.build = ':TSUpdate'
|
M.build = ":TSUpdate"
|
||||||
M.dependencies = {
|
M.dependencies = {
|
||||||
'nvim-treesitter/nvim-treesitter-textobjects'
|
"nvim-treesitter/nvim-treesitter-textobjects"
|
||||||
}
|
}
|
||||||
|
|
||||||
function M.config ()
|
function M.config ()
|
||||||
@ -11,15 +11,14 @@ function M.config ()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M.treesitter_configs()
|
function M.treesitter_configs()
|
||||||
require 'nvim-treesitter.configs'
|
require("nvim-treesitter.configs").setup(M.treesitter_config_setup)
|
||||||
.setup(M.treesitter_config_setup)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
M.treesitter_config_setup = {
|
M.treesitter_config_setup = {
|
||||||
-- Add languages to be installed here that you want installed for treesitter
|
-- Add languages to be installed here that you want installed for treesitter
|
||||||
ensure_installed = {
|
ensure_installed = {
|
||||||
'bash', 'c', 'cpp', 'go', 'lua', 'python', 'rust',
|
"bash", "c", "cpp", "go", "lua", "python", "rust",
|
||||||
'tsx', 'javascript', 'typescript', 'vimdoc', 'vim',
|
"tsx", "javascript", "typescript", "vimdoc", "vim",
|
||||||
},
|
},
|
||||||
|
|
||||||
auto_install = true,
|
auto_install = true,
|
||||||
@ -34,10 +33,10 @@ M.treesitter_config_setup = {
|
|||||||
incremental_selection = {
|
incremental_selection = {
|
||||||
enable = true,
|
enable = true,
|
||||||
keymaps = {
|
keymaps = {
|
||||||
init_selection = '<c-space>',
|
init_selection = "<c-space>",
|
||||||
node_incremental = '<c-space>',
|
node_incremental = "<c-space>",
|
||||||
scope_incremental = '<c-s>',
|
scope_incremental = "<c-s>",
|
||||||
node_decremental = '<M-space>',
|
node_decremental = "<M-space>",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -48,22 +47,22 @@ M.treesitter_config_setup = {
|
|||||||
lookahead = true,
|
lookahead = true,
|
||||||
keymaps = {
|
keymaps = {
|
||||||
-- You can use the capture groups defined in textobjects.scm
|
-- You can use the capture groups defined in textobjects.scm
|
||||||
['aa'] = '@parameter.outer',
|
["aa"] = "@parameter.outer",
|
||||||
['ia'] = '@parameter.inner',
|
["ia"] = "@parameter.inner",
|
||||||
['af'] = '@function.outer',
|
["af"] = "@function.outer",
|
||||||
['if'] = '@function.inner',
|
["if"] = "@function.inner",
|
||||||
['ac'] = '@class.outer',
|
["ac"] = "@class.outer",
|
||||||
['ic'] = '@class.inner',
|
["ic"] = "@class.inner",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
swap = {
|
swap = {
|
||||||
enable = true,
|
enable = true,
|
||||||
swap_next = {
|
swap_next = {
|
||||||
['<leader>a'] = '@parameter.inner',
|
["<leader>a"] = "@parameter.inner",
|
||||||
},
|
},
|
||||||
swap_previous = {
|
swap_previous = {
|
||||||
['<leader>A'] = '@parameter.inner',
|
["<leader>A"] = "@parameter.inner",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -72,20 +71,20 @@ M.treesitter_config_setup = {
|
|||||||
-- whether to set jumps in the jumplist
|
-- whether to set jumps in the jumplist
|
||||||
set_jumps = true,
|
set_jumps = true,
|
||||||
goto_next_start = {
|
goto_next_start = {
|
||||||
[']m'] = '@function.outer',
|
["]m"] = "@function.outer",
|
||||||
[']]'] = '@class.outer',
|
["]]"] = "@class.outer",
|
||||||
},
|
},
|
||||||
goto_next_end = {
|
goto_next_end = {
|
||||||
[']M'] = '@function.outer',
|
["]M"] = "@function.outer",
|
||||||
[']['] = '@class.outer',
|
["]["] = "@class.outer",
|
||||||
},
|
},
|
||||||
goto_previous_start = {
|
goto_previous_start = {
|
||||||
['[m'] = '@function.outer',
|
["[m"] = "@function.outer",
|
||||||
['[['] = '@class.outer',
|
["[["] = "@class.outer",
|
||||||
},
|
},
|
||||||
goto_previous_end = {
|
goto_previous_end = {
|
||||||
['[M'] = '@function.outer',
|
["[M"] = "@function.outer",
|
||||||
['[]'] = '@class.outer',
|
["[]"] = "@class.outer",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user