Browse Source

feat: update some minor config stuff

master
Tovi Jaeschke-Rogers 7 months ago
parent
commit
d74b68eba2
14 changed files with 300 additions and 327 deletions
  1. +4
    -2
      .config/nvim/lua/tovi/core/remaps.lua
  2. +47
    -37
      .config/nvim/lua/tovi/plugins/copilot.lua
  3. +14
    -14
      .config/nvim/lua/tovi/plugins/formatting.lua
  4. +35
    -42
      .config/nvim/lua/tovi/plugins/fugitive.lua
  5. +3
    -3
      .config/nvim/lua/tovi/plugins/gitsigns.lua
  6. +7
    -7
      .config/nvim/lua/tovi/plugins/harpoon.lua
  7. +3
    -7
      .config/nvim/lua/tovi/plugins/linting.lua
  8. +2
    -7
      .config/nvim/lua/tovi/plugins/lsp/lspconfig.lua
  9. +3
    -7
      .config/nvim/lua/tovi/plugins/lsp/mason.lua
  10. +10
    -6
      .config/nvim/lua/tovi/plugins/lualine.lua
  11. +10
    -8
      .config/nvim/lua/tovi/plugins/nvim-cmp.lua
  12. +25
    -34
      .config/nvim/lua/tovi/plugins/nvim-treesitter.lua
  13. +86
    -102
      .config/nvim/lua/tovi/plugins/oil.lua
  14. +51
    -51
      .config/nvim/lua/tovi/plugins/telescope.lua

+ 4
- 2
.config/nvim/lua/tovi/core/remaps.lua View File

@ -10,7 +10,9 @@ vim.keymap.set("n", "<leader>hs", "<cmd>split<cr>", { desc = "Open horizontal sp
vim.keymap.set("n", "<leader>vs", "<cmd>vsplit<cr>", { desc = "Open vertical spilt" })
-- Spell-check
vim.keymap.set("n", "<leader>o", vim.cmd("setlocal spell! spelllang=en_au"), { desc = "Toggle spell check" })
vim.keymap.set("n", "<leader>o", function()
vim.cmd("setlocal spell! spelllang=en_au")
end, { desc = "Toggle spell check" })
-- Map Q to nop
vim.keymap.set("n", "Q", "<nop>", { desc = "Remap Q to <nop> because Q is the worst" })
@ -47,4 +49,4 @@ vim.keymap.set(
{ desc = "Search and replace for word under cursor" }
)
vim.keymap.set('t', '<C-space>', "<C-\\><C-n>", { silent = true })
vim.keymap.set("t", "<C-space>", "<C-\\><C-n>", { silent = true })

+ 47
- 37
.config/nvim/lua/tovi/plugins/copilot.lua View File

@ -1,41 +1,51 @@
return {
'zbirenbaum/copilot.lua',
cmd = "Copilot",
event = "InsertEnter",
config = function()
require("copilot").setup({
panel = {
enabled = true,
auto_refresh = false,
keymap = {
jump_prev = "[[",
jump_next = "]]",
accept = "<CR>",
refresh = "gr",
open = "<M-CR>"
{
'zbirenbaum/copilot.lua',
cmd = "Copilot",
event = "InsertEnter",
config = function()
require("copilot").setup({
panel = {
enabled = true,
auto_refresh = false,
keymap = {
jump_prev = "[[",
jump_next = "]]",
accept = "<CR>",
refresh = "gr",
open = "<M-CR>"
},
layout = {
position = "bottom", -- | top | left | right
ratio = 0.4
},
},
layout = {
position = "bottom", -- | top | left | right
ratio = 0.4
suggestion = {
enabled = false,
auto_trigger = true,
debounce = 75,
keymap = {
accept = ",,",
accept_word = false,
accept_line = false,
next = "<C-n>",
prev = "<C-p>",
dismiss = "<C-]>",
},
},
},
suggestion = {
enabled = true,
auto_trigger = true,
debounce = 75,
keymap = {
accept = ",,",
accept_word = false,
accept_line = false,
next = "<C-n>",
prev = "<C-p>",
dismiss = "<C-]>",
},
},
filetypes = {
},
copilot_node_command = 'node', -- Node.js version must be > 18.x
server_opts_overrides = {},
})
end,
copilot_node_command = 'node', -- Node.js version must be > 18.x
server_opts_overrides = {},
})
end,
},
{
"zbirenbaum/copilot-cmp",
event = "BufEnter",
dependencies = {
"zbirenbaum/copilot.lua",
},
config = function()
require("copilot_cmp").setup()
end,
}
}

+ 14
- 14
.config/nvim/lua/tovi/plugins/formatting.lua View File

@ -8,26 +8,26 @@ return {
formatters_by_ft = {
lua = { "stylua" },
go = { "goimports", "gofmt" },
javascript = { "prettier" },
typescript = { "prettier" },
vue = { "prettier" },
css = { "prettier" },
html = { "prettier" },
markdown = { "prettier" },
javascript = { "prettierd" },
typescript = { "prettierd" },
vue = { "prettierd" },
css = { "prettierd" },
html = { "prettierd" },
markdown = { "prettierd" },
json = { "fixjson" },
rust = { "rustfmt" },
shell = { "shfmt", "shellcheck" },
python = { "isort", "black" },
php = { "phpcbf" }
},
-- format_on_save = {
-- lsp_fallback = true,
-- async = false,
-- timeout_ms = 500,
-- },
-- format_after_save = {
-- lsp_fallback = true,
-- },
format_on_save = {
lsp_fallback = true,
async = false,
timeout_ms = 500,
},
format_after_save = {
lsp_fallback = true,
},
log_level = vim.log.levels.WARN,
notify_on_error = false,
})


+ 35
- 42
.config/nvim/lua/tovi/plugins/fugitive.lua View File

@ -7,47 +7,40 @@ return {
vim.opt.diffopt = vim.opt.diffopt + "vertical"
vim.opt.display = vim.opt.display + "lastline"
local function gitBlame(lines)
local current_file = vim.fn.expand('%:p')
local range = lines[1] .. "," .. lines[2]
local cmd = string.format("git -C %s blame -C -C -C -L %s %s | awk '{print $1}'", vim.fn.shellescape(vim.fn.fnamemodify(current_file, ':h')), range, vim.fn.fnamemodify(current_file, ':t'))
local handle = io.popen(cmd)
local result = handle:read("*a")
handle:close()
return result
end
vim.keymap.set('n', '<leader>gC', function ()
vim.cmd(string.format('Git show %s', gitBlame({vim.fn.line('.'), vim.fn.line('.')})))
end)
local options = { noremap = true, silent = true }
vim.keymap.set('n', '<leader>gg', '<cmd>Git<CR>', options)
vim.keymap.set('n', '<leader>gp', '<cmd>Git push<CR>', options)
vim.keymap.set('n', '<leader>gP', '<cmd>Git pull<CR>', options)
vim.keymap.set('n', '<leader>ga', '<cmd>Git add .<CR>', options)
vim.keymap.set('n', '<leader>gA', '<cmd>Git add<CR>', options)
vim.keymap.set('n', '<leader>gc', '<cmd>Git commit<CR>', options)
-- vim.keymap.set('n', '<leader>gC', '<cmd>Git commit -a<CR>', options)
vim.keymap.set('v', '<leader>gl', function ()
local startPos = vim.fn.getpos("'<")
local endPos = vim.fn.getpos("'>")
local startLine = startPos[2]
local endLine = endPos[2]
if (startLine == 0 or endLine == 0)
then
vim.notify(vim.inspect(vim.fn.getpos("'<")) .. " to " .. vim.inspect(vim.fn.getpos("'>")))
-- vim.notify('Error getting start or end line', vim.log.levels.ERROR)
return
end
vim.cmd(string.format('Git log -L %d,%d:%s', startLine, endLine, vim.fn.expand("%:.")))
end, options);
local fugitive_augroup = vim.api.nvim_create_augroup("fugitive_mappings", { clear = true })
local function set_fugitive_mappings()
local opts = { noremap = true, silent = true }
vim.api.nvim_buf_set_keymap(0, "n", "<leader>gp", "<cmd>Git push<CR>", opts)
vim.api.nvim_buf_set_keymap(0, "n", "<leader>gP", "<cmd>Git pull<CR>", opts)
vim.api.nvim_buf_set_keymap(0, "n", "<leader>gc", "<cmd>Git commit<CR>", opts)
end
-- Create an autocmd to trigger the function when entering a Fugitive buffer
vim.api.nvim_create_autocmd("FileType", {
group = fugitive_augroup,
pattern = "fugitive",
callback = set_fugitive_mappings,
})
local opts = { noremap = true, silent = true }
vim.keymap.set("n", "<leader>gg", "<cmd>Git<CR>", opts)
vim.keymap.set("v", "<leader>gl", function()
local startPos = vim.fn.getpos("'<")
local endPos = vim.fn.getpos("'>")
local startLine = startPos[2]
local endLine = endPos[2]
if startLine == 0 or endLine == 0 then
vim.notify(vim.inspect(vim.fn.getpos("'<")) .. " to " .. vim.inspect(vim.fn.getpos("'>")))
return
end
vim.cmd(string.format("Git log -L %d,%d:%s", startLine, endLine, vim.fn.expand("%:.")))
end, opts)
end,
}

+ 3
- 3
.config/nvim/lua/tovi/plugins/gitsigns.lua View File

@ -2,9 +2,9 @@ return {
"lewis6991/gitsigns.nvim",
event = { "BufReadPre", "BufNewFile" },
config = function ()
require('gitsigns').setup {
require('gitsigns').setup({
signs = {
add = {hl = 'GitSignsAdd' , text = '', numhl='GitSignsAddNr' , linehl='GitSignsAddLn'},
add = {hl = 'GitSignsAdd' , text = '+', numhl='GitSignsAddNr' , linehl='GitSignsAddLn'},
change = {hl = 'GitSignsChange', text = '', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'},
delete = {hl = 'GitSignsDelete', text = '_', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'},
topdelete = {hl = 'GitSignsDelete', text = '', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'},
@ -43,6 +43,6 @@ return {
yadm = {
enable = false
},
}
})
end
}

+ 7
- 7
.config/nvim/lua/tovi/plugins/harpoon.lua View File

@ -1,6 +1,6 @@
return {
"ThePrimeagen/harpoon",
branch = "harpoon2",
branch = "harpoon2",
dependencies = {
"nvim-lua/plenary.nvim",
},
@ -13,27 +13,27 @@ return {
local keymap = vim.keymap
keymap.set("n", "<leader>a", function ()
keymap.set("n", "<leader>a", function()
harpoon:list():add()
end, { desc = "Mark file with harpoon" })
keymap.set("n", "<C-e>", function ()
keymap.set("n", "<C-e>", function()
harpoon.ui:toggle_quick_menu(harpoon:list())
end, { desc = "Toggle quick menu for harpoon" })
keymap.set("n", "<A-h>", function()
keymap.set("n", "<leader>1", function()
harpoon:list():select(1)
end, { desc = "Go to first harpoon file" })
keymap.set("n", "<A-j>", function()
keymap.set("n", "<leader>2", function()
harpoon:list():select(2)
end, { desc = "Go to second harpoon file" })
keymap.set("n", "<A-k>", function()
keymap.set("n", "<leader>3", function()
harpoon:list():select(3)
end, { desc = "Go to third harpoon file" })
keymap.set("n", "<A-l>", function()
keymap.set("n", "<leader>4", function()
harpoon:list():select(4)
end, { desc = "Go to fourth harpoon file" })
end,


+ 3
- 7
.config/nvim/lua/tovi/plugins/linting.lua View File

@ -9,10 +9,6 @@ return {
WARNING = vim.diagnostic.severity.WARN,
}
lint.linters.ecs = {
cmd = "ecs",
}
lint.linters.phpcs = {
cmd = 'phpcs',
stdin = true,
@ -55,9 +51,9 @@ return {
}
lint.linters_by_ft = {
javascript = { "eslint" },
typescript = { "eslint" },
vue = { "eslint" },
javascript = { "eslint_d" },
typescript = { "eslint_d" },
vue = { "eslint_d" },
json = { "jsonlint" },
markdown = { "markdownlint" },
php = { "phpcs" },


+ 2
- 7
.config/nvim/lua/tovi/plugins/lsp/lspconfig.lua View File

@ -13,7 +13,7 @@ return {
-- import cmp-nvim-lsp plugin
local cmp_nvim_lsp = require("cmp_nvim_lsp")
local keymap = vim.keymap -- for conciseness
local keymap = vim.keymap
local opts = { noremap = true, silent = true }
local on_attach = function(_, bufnr)
@ -81,9 +81,6 @@ return {
opts.desc = "Show documentation for what is under cursor"
keymap.set("n", "K", vim.lsp.buf.hover, opts) -- show documentation for what is under cursor
opts.desc = "Restart LSP"
keymap.set("n", "<leader>rs", ":LspRestart<CR>", opts) -- mapping to restart lsp if necessary
end
-- override default floating window border if not set
@ -150,7 +147,6 @@ return {
})
local function get_typescript_server_path(root_dir)
local global_ts = base_path .. '/typescript/lib'
local found_ts = ''
local function check_dir(path)
@ -167,7 +163,7 @@ return {
end
lspconfig.volar.setup({
-- capabilities = capabilities,
capabilities = capabilities,
on_attach = on_attach,
filetypes = {
"javascript",
@ -247,6 +243,5 @@ return {
capabilities = capabilities,
on_attach = on_attach,
})
end,
}

+ 3
- 7
.config/nvim/lua/tovi/plugins/lsp/mason.lua View File

@ -30,13 +30,9 @@ return {
"tsserver",
"html",
"cssls",
"tailwindcss",
"svelte",
"lua_ls",
"emmet_ls",
-- "pyright",
"intelephense",
-- "gopls",
},
automatic_installation = true,
})
@ -44,14 +40,14 @@ return {
mason_tool_installer.setup({
ensure_installed = {
"prettier",
"eslint_d",
"prettierd",
"eslint",
"eslint_d",
"jsonlint",
"markdownlint",
"phpcbf",
"phpcs",
-- "gospel",
"golangci-lint",
-- "pylint",
"hadolint",
"gofumpt",
"goimports",


+ 10
- 6
.config/nvim/lua/tovi/plugins/lualine.lua View File

@ -1,30 +1,34 @@
return {
"nvim-lualine/lualine.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
dependencies = {
"nvim-tree/nvim-web-devicons",
"letieu/harpoon-lualine",
},
config = function()
local lualine = require("lualine")
local lazy_status = require("lazy.status")
lualine.setup({
options = {
theme = 'kanagawa',
component_separators = { left = '', right = '' },
section_separators = { left = '', right = '' },
theme = "kanagawa",
component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" },
globalstatus = true,
},
sections = {
lualine_b = {
{ "diagnostics" },
{ "branch" },
{ "diff" },
{ "diagnostics" },
},
lualine_c = {
{ "filename", file_status = true, path = 1 },
{ "harpoon2" },
},
lualine_x = {
{
lazy_status.updates,
cond = lazy_status.has_updates,
color = { fg = "#ff9e64" },
},
{ "fileformat" },
{ "filetype" },


+ 10
- 8
.config/nvim/lua/tovi/plugins/nvim-cmp.lua View File

@ -2,12 +2,13 @@ return {
"hrsh7th/nvim-cmp",
event = "InsertEnter",
dependencies = {
"hrsh7th/cmp-buffer", -- source for text in buffer
"hrsh7th/cmp-path", -- source for file system paths
"L3MON4D3/LuaSnip", -- snippet engine
"saadparwaiz1/cmp_luasnip", -- for autocompletion
"rafamadriz/friendly-snippets", -- useful snippets
"onsails/lspkind.nvim", -- vs-code like pictograms
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
"rafamadriz/friendly-snippets",
"onsails/lspkind.nvim",
"kristijanhusak/vim-dadbod-completion",
},
config = function()
@ -41,8 +42,8 @@ return {
mapping = cmp.mapping.preset.insert({
["<C-k>"] = cmp.mapping.select_prev_item(), -- previous suggestion
["<C-j>"] = cmp.mapping.select_next_item(), -- next suggestion
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-u>"] = cmp.mapping.scroll_docs(-4),
["<C-d>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions
["<C-e>"] = cmp.mapping.abort(), -- close completion window
["<CR>"] = cmp.mapping.confirm({ select = true }),
@ -76,6 +77,7 @@ return {
-- sources for autocompletion
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "copilot" },
{ name = "luasnip" },
{ name = "buffer" },
{ name = "path" },


+ 25
- 34
.config/nvim/lua/tovi/plugins/nvim-treesitter.lua View File

@ -3,23 +3,12 @@ return {
"nvim-treesitter/nvim-treesitter",
event = { "BufReadPre", "BufNewFile" },
build = ":TSUpdate",
dependencies = {
"windwp/nvim-ts-autotag",
},
config = function()
-- import nvim-treesitter plugin
local treesitter = require("nvim-treesitter.configs")
-- configure treesitter
treesitter.setup({
-- enable syntax highlighting
highlight = {
enable = true,
},
-- enable indentation
indent = { enable = true },
-- enable autotagging (w/ nvim-ts-autotag plugin)
autotag = { enable = true },
-- ensure these language parsers are installed
ensure_installed = {
"json",
@ -40,33 +29,35 @@ return {
"dockerfile",
"gitignore",
"php",
"blade",
},
-- enable nvim-ts-context-commentstring plugin for commenting tsx and jsx
context_commentstring = {
enable = true,
enable_autocmd = false,
},
-- auto install above language parsers
auto_install = true,
})
-- enable syntax highlighting
highlight = {
enable = true,
},
-- enable indentation
indent = { enable = true },
-- enable autotagging
autotag = { enable = true },
})
local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
parser_config.blade = {
install_info = {
url = "https://github.com/EmranMR/tree-sitter-blade",
files = { "src/parser.c" },
branch = "main",
},
filetype = "blade"
}
parser_config.blade = {
install_info = {
url = "https://github.com/EmranMR/tree-sitter-blade",
files = { "src/parser.c" },
branch = "main",
},
filetype = "blade",
}
vim.filetype.add({
pattern = {
['.*%.blade%.php'] = 'blade',
}
})
end,
},
vim.filetype.add({
pattern = {
[".*%.blade%.php"] = "blade",
},
})
end,
},
}

+ 86
- 102
.config/nvim/lua/tovi/plugins/oil.lua View File

@ -1,105 +1,89 @@
return {
'stevearc/oil.nvim',
opts = {},
-- Optional dependencies
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function ()
require("oil").setup({
default_file_explorer = true,
-- columns = {
-- "icon",
-- "permissions",
-- "size",
-- "mtime",
-- },
buf_options = {
buflisted = false,
bufhidden = "hide",
},
win_options = {
wrap = false,
signcolumn = "no",
cursorcolumn = false,
foldcolumn = "0",
spell = false,
list = false,
conceallevel = 3,
concealcursor = "nvic",
},
delete_to_trash = false,
skip_confirm_for_simple_edits = false,
prompt_save_on_select_new_entry = true,
cleanup_delay_ms = 2000,
keymaps = {
["g?"] = "actions.show_help",
["<CR>"] = "actions.select",
["<C-s>"] = "actions.select_vsplit",
["<C-h>"] = false,
["<C-t>"] = "actions.select_tab",
["<C-v>"] = "actions.preview",
["<C-c>"] = "actions.close",
["<C-l>"] = false,
["-"] = "actions.parent",
["_"] = "actions.open_cwd",
["`"] = "actions.cd",
["~"] = "actions.tcd",
["gs"] = "actions.change_sort",
["gx"] = "actions.open_external",
["g."] = "actions.toggle_hidden",
},
use_default_keymaps = false,
view_options = {
show_hidden = true,
is_hidden_file = function(name, bufnr)
return vim.startswith(name, ".")
end,
is_always_hidden = function(name, bufnr)
return false
end,
sort = {
{ "type", "asc" },
{ "name", "asc" },
},
},
float = {
padding = 2,
max_width = 0,
max_height = 0,
border = "rounded",
win_options = {
winblend = 0,
},
override = function(conf)
return conf
end,
},
preview = {
max_width = 0.9,
min_width = { 40, 0.4 },
width = nil,
max_height = 0.9,
min_height = { 5, 0.1 },
height = nil,
border = "rounded",
win_options = {
winblend = 0,
},
},
progress = {
max_width = 0.9,
min_width = { 40, 0.4 },
width = nil,
max_height = { 10, 0.9 },
min_height = { 5, 0.1 },
height = nil,
border = "rounded",
minimized_border = "none",
win_options = {
winblend = 0,
},
},
})
"stevearc/oil.nvim",
opts = {},
-- Optional dependencies
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
require("oil").setup({
default_file_explorer = true,
buf_options = {
buflisted = false,
bufhidden = "hide",
},
win_options = {
wrap = false,
signcolumn = "no",
cursorcolumn = false,
foldcolumn = "0",
spell = false,
list = false,
conceallevel = 3,
concealcursor = "nvic",
},
delete_to_trash = false,
skip_confirm_for_simple_edits = false,
prompt_save_on_select_new_entry = true,
cleanup_delay_ms = 2000,
keymaps = {
["g?"] = "actions.show_help",
["<CR>"] = "actions.select",
["<C-s>"] = "actions.select_vsplit",
["<C-h>"] = false,
["<C-t>"] = "actions.select_tab",
["<C-v>"] = "actions.preview",
["<C-c>"] = "actions.close",
["<C-l>"] = false,
["-"] = "actions.parent",
["_"] = "actions.open_cwd",
["`"] = "actions.cd",
["~"] = "actions.tcd",
["gs"] = "actions.change_sort",
["gx"] = "actions.open_external",
["g."] = "actions.toggle_hidden",
},
use_default_keymaps = false,
view_options = {
show_hidden = true,
is_hidden_file = function(name, bufnr)
return vim.startswith(name, ".")
end,
is_always_hidden = function(name, bufnr)
return false
end,
sort = {
{ "type", "asc" },
{ "name", "asc" },
},
},
preview = {
max_width = 0.9,
min_width = { 40, 0.4 },
width = nil,
max_height = 0.9,
min_height = { 5, 0.1 },
height = nil,
border = "rounded",
win_options = {
winblend = 0,
},
},
progress = {
max_width = 0.9,
min_width = { 40, 0.4 },
width = nil,
max_height = { 10, 0.9 },
min_height = { 5, 0.1 },
height = nil,
border = "rounded",
minimized_border = "none",
win_options = {
winblend = 0,
},
},
})
vim.keymap.set("n", "-", "<CMD>Oil<CR>", { desc = "Open parent directory" })
end
vim.keymap.set("n", "-", function()
vim.cmd("Oil")
end, { desc = "Open parent directory" })
end,
}

+ 51
- 51
.config/nvim/lua/tovi/plugins/telescope.lua View File

@ -5,7 +5,7 @@ return {
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
"nvim-tree/nvim-web-devicons",
"debugloop/telescope-undo.nvim",
"nvim-telescope/telescope-ui-select.nvim",
"nvim-telescope/telescope-ui-select.nvim",
},
config = function()
local telescope = require("telescope")
@ -20,6 +20,7 @@ return {
opts = opts or {}
filepath = vim.fn.expand(filepath)
---@diagnostic disable-next-line: undefined-field
vim.loop.fs_stat(filepath, function(_, stat)
if not stat then
return
@ -36,7 +37,6 @@ return {
telescope.setup({
defaults = {
file_sorter = sorters.get_fzy_sorter,
prompt_prefix = " >",
color_devicons = true,
buffer_previewer_maker = truncate_large_files,
@ -84,40 +84,41 @@ return {
},
},
},
["ui-select"] = {
require("telescope.themes").get_dropdown({})
},
["ui-select"] = {
require("telescope.themes").get_dropdown({}),
},
},
})
telescope.load_extension("fzf")
telescope.load_extension("undo")
telescope.load_extension("ui-select")
telescope.load_extension("ui-select")
local git_branches = function()
builtin.git_branches({
attach_mappings = function(_, map)
map("i", "<c-d>", actions.git_delete_branch)
map("n", "<c-d>", actions.git_delete_branch)
return true
end,
})
end
-- We cache the results of "git rev-parse"
-- Process creation is expensive in Windows, so this reduces latency
local is_inside_work_tree = {}
local project_files = function()
local cwd = vim.fn.getcwd()
if is_inside_work_tree[cwd] == nil then
vim.fn.system("git rev-parse --is-inside-work-tree")
is_inside_work_tree[cwd] = vim.v.shell_error == 0
end
local find_files = function()
local ran, errorMessage = pcall(function()
if is_inside_work_tree[cwd] then
builtin.git_files({ show_untracked = true, hidden = true })
end)
if not ran then
builtin.find_files({ hidden = true })
else
builtin.find_files({})
end
end
-- set keymaps
local keymap = vim.keymap -- for conciseness
keymap.set("n", "<C-g>", function () builtin.live_grep({ hidden = true }) end, {})
keymap.set("n", "<C-p>", find_files, {})
keymap.set("n", "<C-g>", function()
builtin.live_grep({ hidden = true })
end, {})
keymap.set("n", "<C-p>", project_files, {})
keymap.set("n", "<leader>fr", builtin.resume, {})
@ -127,43 +128,42 @@ return {
keymap.set("n", "<leader>m", builtin.marks, {})
keymap.set("n", "<leader>ch", builtin.command_history, {})
keymap.set("n", "<leader>gb", git_branches, {})
keymap.set("n", "<leader>vh", builtin.help_tags, {})
keymap.set("n", "<leader>gb", function()
builtin.git_branches({
attach_mappings = function(_, map)
map("i", "<c-d>", actions.git_delete_branch)
map("n", "<c-d>", actions.git_delete_branch)
return true
end,
})
end, {})
keymap.set("n", "<leader>ds", builtin.lsp_document_symbols, {})
keymap.set("n", "<leader>ws", builtin.lsp_workspace_symbols, {})
keymap.set("n", "<leader>dws", builtin.lsp_dynamic_workspace_symbols, {})
keymap.set("n", "<leader>gc", builtin.git_commits, {})
keymap.set("n", "<leader>gf", function ()
builtin.grep_string({
search = vim.fn.expand("<cword>"),
})
end)
keymap.set("n", "<leader>vh", builtin.help_tags, {})
keymap.set("n", "<leader>gF", function ()
builtin.grep_string({
search = vim.fn.expand("<cWORD>"),
})
end)
keymap.set("n", "<leader>ds", builtin.lsp_document_symbols, {})
keymap.set("n", "<leader>ws", builtin.lsp_workspace_symbols, {})
keymap.set("n", "<leader>dws", builtin.lsp_dynamic_workspace_symbols, {})
keymap.set("n", "<leader>gD", function ()
builtin.find_files({
search_file = vim.fn.expand("<cword>"),
})
end)
keymap.set("n", "<leader>gf", function()
builtin.grep_string({
search = vim.fn.expand("<cword>"),
})
end)
vim.keymap.set("n", "<leader>u", "<cmd>Telescope undo<cr>")
keymap.set("n", "<leader>gF", function()
builtin.grep_string({
search = vim.fn.expand("<cWORD>"),
})
end)
local function telescopeDotfiles()
keymap.set("n", "<leader>gD", function()
builtin.find_files({
prompt_title = "< VimRC >",
cwd = vim.fn.expand("~/dotfiles"),
hidden = true,
search_file = vim.fn.expand("<cword>"),
})
end
vim.api.nvim_create_user_command('TelescopeDotfiles', telescopeDotfiles, {})
end)
vim.keymap.set("n", "<leader>u", "<cmd>Telescope undo<cr>")
end,
}

Loading…
Cancel
Save