Add lsp servers
parent
acf86e8285
commit
3fec732003
@ -1,61 +1,61 @@
|
|||||||
local function config()
|
local function 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)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function tab_mapping(fallback)
|
local function tab_mapping(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_next_item()
|
cmp.select_next_item()
|
||||||
elseif luasnip.expand_or_locally_jumpable() then
|
elseif luasnip.expand_or_locally_jumpable() then
|
||||||
luasnip.expand_or_jump()
|
luasnip.expand_or_jump()
|
||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function back_tab_mapping(fallback)
|
local function back_tab_mapping(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_prev_item()
|
cmp.select_prev_item()
|
||||||
elseif luasnip.locally_jumpable(-1) then
|
elseif luasnip.locally_jumpable(-1) then
|
||||||
luasnip.jump(-1)
|
luasnip.jump(-1)
|
||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
cmp.setup {
|
cmp.setup {
|
||||||
enabled = true,
|
enabled = true,
|
||||||
|
|
||||||
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,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'hrsh7th/nvim-cmp',
|
'hrsh7th/nvim-cmp',
|
||||||
config = config,
|
config = config,
|
||||||
dependencies = {
|
dependencies = {
|
||||||
'saadparwaiz1/cmp_luasnip',
|
'saadparwaiz1/cmp_luasnip',
|
||||||
'hrsh7th/cmp-nvim-lsp',
|
'hrsh7th/cmp-nvim-lsp',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,7 @@
|
|||||||
local config = function()
|
|
||||||
local wk = require 'which-key'
|
|
||||||
wk.setup()
|
|
||||||
wk.register {
|
|
||||||
['<leader>c'] = { name = '[C]ode', _ = 'which_key_ignore' },
|
|
||||||
['<leader>d'] = { name = '[D]ocument', _ = 'which_key_ignore' },
|
|
||||||
['<leader>g'] = { name = '[G]it', _ = 'which_key_ignore' },
|
|
||||||
['<leader>h'] = { name = 'More git', _ = 'which_key_ignore' },
|
|
||||||
['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' },
|
|
||||||
['<leader>s'] = { name = '[S]earch', _ = 'which_key_ignore' },
|
|
||||||
['<leader>w'] = { name = '[W]orkspace', _ = 'which_key_ignore' },
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'folke/which-key.nvim',
|
'tpope/vim-surround',
|
||||||
config = config,
|
tag = 'v2.2',
|
||||||
dependencies = {
|
dependencies = {
|
||||||
{ 'tpope/vim-sleuth', tag = 'v2.0' },
|
{ 'tpope/vim-sleuth', tag = 'v2.0' },
|
||||||
{ 'tpope/vim-surround', tag = 'v2.2' },
|
},
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
@ -1,93 +0,0 @@
|
|||||||
local function on_attach(_, bufnr)
|
|
||||||
local nmap = function(keys, func, desc)
|
|
||||||
if desc then
|
|
||||||
desc = 'LSP: ' .. desc
|
|
||||||
end
|
|
||||||
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
|
|
||||||
end
|
|
||||||
|
|
||||||
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', require('telescope.builtin').lsp_definitions, '[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', require('telescope.builtin').lsp_type_definitions, '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')
|
|
||||||
nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
|
|
||||||
|
|
||||||
-- 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(_)
|
|
||||||
vim.lsp.buf.format()
|
|
||||||
end, { desc = 'Format current buffer with LSP' })
|
|
||||||
end
|
|
||||||
|
|
||||||
local function config()
|
|
||||||
local mason = require 'mason'
|
|
||||||
local mason_lspconfig = require 'mason-lspconfig'
|
|
||||||
local neodev = require 'neodev'
|
|
||||||
|
|
||||||
mason.setup()
|
|
||||||
neodev.setup()
|
|
||||||
|
|
||||||
local servers = {
|
|
||||||
-- clangd = {},
|
|
||||||
-- pyright = {},
|
|
||||||
-- rust_analyzer = {},
|
|
||||||
-- tsserver = {},
|
|
||||||
-- html = { filetypes = { 'html', 'twig', 'hbs'} },
|
|
||||||
gopls = {},
|
|
||||||
lua_ls = {
|
|
||||||
Lua = {
|
|
||||||
workspace = { checkThirdParty = false },
|
|
||||||
telemetry = { enable = false },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
||||||
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
|
|
||||||
|
|
||||||
mason_lspconfig.setup {
|
|
||||||
ensure_installed = vim.tbl_keys(servers),
|
|
||||||
}
|
|
||||||
|
|
||||||
mason_lspconfig.setup_handlers {
|
|
||||||
function(server_name)
|
|
||||||
require('lspconfig')[server_name].setup {
|
|
||||||
capabilities = capabilities,
|
|
||||||
on_attach = on_attach,
|
|
||||||
settings = servers[server_name],
|
|
||||||
filetypes = (servers[server_name] or {}).filetypes,
|
|
||||||
}
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
return {
|
|
||||||
-- LSP Configuration & Plugins
|
|
||||||
'neovim/nvim-lspconfig',
|
|
||||||
config = config,
|
|
||||||
dependencies = {
|
|
||||||
-- Automatically install LSPs to stdpath for neovim
|
|
||||||
'williamboman/mason.nvim',
|
|
||||||
'williamboman/mason-lspconfig.nvim',
|
|
||||||
-- Useful status updates for LSP
|
|
||||||
{ 'j-hui/fidget.nvim', tag = 'legacy', opts = {} },
|
|
||||||
-- Additional lua configuration, makes nvim stuff amazing!
|
|
||||||
'folke/neodev.nvim',
|
|
||||||
'folke/trouble.nvim',
|
|
||||||
},
|
|
||||||
}
|
|
@ -0,0 +1,112 @@
|
|||||||
|
# chezmoi:template:left-delimiter=--{{
|
||||||
|
--{{- /* vim: set filetype=lua: */ -}}
|
||||||
|
local function on_attach(_, buffer)
|
||||||
|
local function nmap(keys, func, desc)
|
||||||
|
if desc then
|
||||||
|
desc = 'LSP: ' .. desc
|
||||||
|
end
|
||||||
|
vim.keymap.set('n', keys, func, { buffer = buffer, desc = desc })
|
||||||
|
end
|
||||||
|
|
||||||
|
local function inspect_workspace_folders()
|
||||||
|
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||||
|
end
|
||||||
|
|
||||||
|
local function format_buffer(_)
|
||||||
|
vim.lsp.buf.format()
|
||||||
|
end
|
||||||
|
|
||||||
|
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
|
||||||
|
nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
|
||||||
|
|
||||||
|
local builtin = require 'telescope.builtin'
|
||||||
|
nmap('gd', builtin.lsp_definitions, '[G]oto [D]efinition')
|
||||||
|
nmap('gr', builtin.lsp_references, '[G]oto [R]eferences')
|
||||||
|
nmap('gI', builtin.lsp_implementations, '[G]oto [I]mplementation')
|
||||||
|
nmap('<leader>D', builtin.lsp_type_definitions, 'Type [D]efinition')
|
||||||
|
nmap('<leader>ds', builtin.lsp_document_symbols, '[D]ocument [S]ymbols')
|
||||||
|
nmap('<leader>ws', builtin.lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
|
||||||
|
|
||||||
|
-- See `:help K` for why this keymap
|
||||||
|
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
|
||||||
|
nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
|
||||||
|
|
||||||
|
-- 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', inspect_workspace_folders, '[W]orkspace [L]ist Folders')
|
||||||
|
|
||||||
|
-- Create a command `:Format` local to the LSP buffer
|
||||||
|
vim.api.nvim_buf_create_user_command(buffer, 'Format', format_buffer, {
|
||||||
|
desc = 'Format current buffer with LSP',
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
local function config()
|
||||||
|
local cmp_nvim_lsp = require 'cmp_nvim_lsp'
|
||||||
|
local lspconfig = require 'lspconfig'
|
||||||
|
local mason = require 'mason'
|
||||||
|
local mason_lspconfig = require 'mason-lspconfig'
|
||||||
|
local neodev = require 'neodev'
|
||||||
|
|
||||||
|
mason.setup()
|
||||||
|
neodev.setup()
|
||||||
|
|
||||||
|
local servers = {
|
||||||
|
bashls = {},
|
||||||
|
bufls = {},
|
||||||
|
taplo = {},
|
||||||
|
dockerls = {},
|
||||||
|
jsonls = {},
|
||||||
|
jqls = {},
|
||||||
|
marksman = {},
|
||||||
|
sqlls = {},
|
||||||
|
vimls = {},
|
||||||
|
yamlls = {},
|
||||||
|
--{{ if lookPath "node" -}}
|
||||||
|
eslint = {},
|
||||||
|
--{{- end }}
|
||||||
|
--{{ if lookPath "go" -}}
|
||||||
|
gopls = {},
|
||||||
|
templ = {},
|
||||||
|
-- golangci_lint_ls = {},
|
||||||
|
--{{- end }}
|
||||||
|
lua_ls = {
|
||||||
|
Lua = {
|
||||||
|
workspace = { checkThirdParty = false },
|
||||||
|
telemetry = { enable = false },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
|
capabilities = cmp_nvim_lsp.default_capabilities(capabilities)
|
||||||
|
|
||||||
|
mason_lspconfig.setup {
|
||||||
|
ensure_installed = vim.tbl_keys(servers),
|
||||||
|
}
|
||||||
|
|
||||||
|
mason_lspconfig.setup_handlers {
|
||||||
|
function(server_name)
|
||||||
|
lspconfig[server_name].setup {
|
||||||
|
capabilities = capabilities,
|
||||||
|
on_attach = on_attach,
|
||||||
|
settings = servers[server_name],
|
||||||
|
filetypes = (servers[server_name] or {}).filetypes,
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
'neovim/nvim-lspconfig',
|
||||||
|
config = config,
|
||||||
|
dependencies = {
|
||||||
|
{ 'williamboman/mason.nvim', tag = 'v1.*' },
|
||||||
|
{ 'williamboman/mason-lspconfig.nvim', tag = 'v1.*' },
|
||||||
|
{ 'j-hui/fidget.nvim', tag = 'legacy', opts = {} },
|
||||||
|
{ 'folke/neodev.nvim', tag = 'v2.*' },
|
||||||
|
{ 'folke/trouble.nvim', tag = 'v2.*' },
|
||||||
|
},
|
||||||
|
}
|
@ -1,12 +1,12 @@
|
|||||||
local function config()
|
local function config()
|
||||||
local luasnip = require 'luasnip'
|
local luasnip = require 'luasnip'
|
||||||
luasnip.setup()
|
luasnip.setup()
|
||||||
luasnip.config.setup({})
|
luasnip.config.setup({})
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'L3MON4D3/LuaSnip',
|
'L3MON4D3/LuaSnip',
|
||||||
config = config,
|
config = config,
|
||||||
tag = 'v2.*',
|
tag = 'v2.*',
|
||||||
dependencies = {},
|
dependencies = {},
|
||||||
}
|
}
|
||||||
|
@ -1,97 +1,97 @@
|
|||||||
-- Telescope live_grep in git root
|
-- Telescope live_grep in git root
|
||||||
-- Function to find the git root directory based on the current buffer's path
|
-- Function to find the git root directory based on the current buffer's path
|
||||||
local function find_git_root()
|
local function find_git_root()
|
||||||
-- Use the current buffer's path as the starting point for the git search
|
-- 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_file = vim.api.nvim_buf_get_name(0)
|
||||||
local current_dir
|
local current_dir
|
||||||
local cwd = vim.fn.getcwd()
|
local cwd = vim.fn.getcwd()
|
||||||
-- If the buffer is not associated with a file, return nil
|
-- If the buffer is not associated with a file, return nil
|
||||||
if current_file == '' then
|
if current_file == '' then
|
||||||
current_dir = cwd
|
current_dir = cwd
|
||||||
else
|
else
|
||||||
-- Extract the directory from the current file's path
|
-- Extract the directory from the current file's path
|
||||||
current_dir = vim.fn.fnamemodify(current_file, ':h')
|
current_dir = vim.fn.fnamemodify(current_file, ':h')
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Find the Git root directory from the current file's path
|
-- 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]
|
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
|
if vim.v.shell_error ~= 0 then
|
||||||
print('Not a git repository. Searching on current working directory')
|
print('Not a git repository. Searching on current working directory')
|
||||||
return cwd
|
return cwd
|
||||||
end
|
end
|
||||||
return git_root
|
return git_root
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 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 = 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, {})
|
||||||
|
|
||||||
local telescope_setup = {
|
local telescope_setup = {
|
||||||
defaults = {
|
defaults = {
|
||||||
mappings = {
|
mappings = {
|
||||||
i = {
|
i = {
|
||||||
['<C-u>'] = false,
|
['<C-u>'] = false,
|
||||||
['<C-d>'] = false,
|
['<C-d>'] = false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local function config()
|
local function 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)
|
telescope.setup(telescope_setup)
|
||||||
|
|
||||||
-- Enable telescope fzf native, if installed
|
-- Enable telescope fzf native, if installed
|
||||||
pcall(telescope.load_extension, 'fzf')
|
pcall(telescope.load_extension, 'fzf')
|
||||||
|
|
||||||
local fuzzy_find = function()
|
local fuzzy_find = function()
|
||||||
-- You can pass additional configuration to telescope to change theme, layout, etc.
|
-- You can pass additional configuration to telescope to change theme, layout, etc.
|
||||||
builtin.current_buffer_fuzzy_find(themes.get_dropdown({
|
builtin.current_buffer_fuzzy_find(themes.get_dropdown({
|
||||||
winblend = 10,
|
winblend = 10,
|
||||||
previewer = false,
|
previewer = false,
|
||||||
}))
|
}))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- See `:help telescope.builtin`
|
-- See `:help telescope.builtin`
|
||||||
vim.keymap.set('n', '<leader>?', builtin.oldfiles, { desc = '[?] Find recently opened files' })
|
vim.keymap.set('n', '<leader>?', builtin.oldfiles, { desc = '[?] Find recently opened files' })
|
||||||
vim.keymap.set('n', '<leader><space>', builtin.buffers, { desc = '[ ] Find existing buffers' })
|
vim.keymap.set('n', '<leader><space>', 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' })
|
||||||
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>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>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>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>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' })
|
||||||
end
|
end
|
||||||
|
|
||||||
local is_make_installed = function()
|
local is_make_installed = function()
|
||||||
return vim.fn.executable('make') == 1
|
return vim.fn.executable('make') == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'nvim-telescope/telescope.nvim',
|
'nvim-telescope/telescope.nvim',
|
||||||
branch = '0.1.x',
|
branch = '0.1.x',
|
||||||
config = config,
|
config = config,
|
||||||
dependencies = {
|
dependencies = {
|
||||||
'nvim-lua/plenary.nvim',
|
'nvim-lua/plenary.nvim',
|
||||||
{
|
{
|
||||||
'nvim-telescope/telescope-fzf-native.nvim',
|
'nvim-telescope/telescope-fzf-native.nvim',
|
||||||
cond = is_make_installed,
|
cond = is_make_installed,
|
||||||
build = 'make',
|
build = 'make',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
local function config()
|
local function config()
|
||||||
vim.cmd.colorscheme 'gruvbox'
|
vim.cmd.colorscheme 'gruvbox'
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'morhetz/gruvbox',
|
'morhetz/gruvbox',
|
||||||
priority = 1000,
|
priority = 1000,
|
||||||
config = config,
|
config = config,
|
||||||
dependencies = {
|
dependencies = {
|
||||||
'nvim-lualine/lualine.nvim',
|
'nvim-lualine/lualine.nvim',
|
||||||
opts = {
|
opts = {
|
||||||
options = {
|
options = {
|
||||||
theme = 'gruvbox',
|
theme = 'gruvbox',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1,93 +1,93 @@
|
|||||||
local treesitter_config_setup = {
|
local 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,
|
||||||
sync_install = false,
|
sync_install = false,
|
||||||
|
|
||||||
modules = {},
|
modules = {},
|
||||||
ignore_install = {},
|
ignore_install = {},
|
||||||
|
|
||||||
highlight = { enable = true },
|
highlight = { enable = true },
|
||||||
indent = { enable = true },
|
indent = { enable = true },
|
||||||
|
|
||||||
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>',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
textobjects = {
|
textobjects = {
|
||||||
select = {
|
select = {
|
||||||
enable = true,
|
enable = true,
|
||||||
-- Automatically jump forward to textobj, similar to targets.vim
|
-- Automatically jump forward to textobj, similar to targets.vim
|
||||||
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',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
move = {
|
move = {
|
||||||
enable = true,
|
enable = true,
|
||||||
-- 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',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local function treesitter_configs()
|
local function treesitter_configs()
|
||||||
require('nvim-treesitter.configs').setup(treesitter_config_setup)
|
require('nvim-treesitter.configs').setup(treesitter_config_setup)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function config()
|
local function config()
|
||||||
vim.defer_fn(treesitter_configs, 0)
|
vim.defer_fn(treesitter_configs, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
-- Highlight, edit, and navigate code
|
-- Highlight, edit, and navigate code
|
||||||
'nvim-treesitter/nvim-treesitter',
|
'nvim-treesitter/nvim-treesitter',
|
||||||
config = config,
|
config = config,
|
||||||
build = ':TSUpdate',
|
build = ':TSUpdate',
|
||||||
dependencies = {
|
dependencies = {
|
||||||
'nvim-treesitter/nvim-treesitter-textobjects',
|
'nvim-treesitter/nvim-treesitter-textobjects',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
local function init()
|
||||||
|
vim.o.timeout = true
|
||||||
|
vim.o.timeoutlen = 300
|
||||||
|
end
|
||||||
|
|
||||||
|
local function config()
|
||||||
|
local wk = require 'which-key'
|
||||||
|
wk.setup()
|
||||||
|
wk.register {
|
||||||
|
['<leader>c'] = { name = '[C]ode', _ = 'which_key_ignore' },
|
||||||
|
['<leader>d'] = { name = '[D]ocument', _ = 'which_key_ignore' },
|
||||||
|
['<leader>g'] = { name = '[G]it', _ = 'which_key_ignore' },
|
||||||
|
['<leader>h'] = { name = 'More git', _ = 'which_key_ignore' },
|
||||||
|
['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' },
|
||||||
|
['<leader>s'] = { name = '[S]earch', _ = 'which_key_ignore' },
|
||||||
|
['<leader>w'] = { name = '[W]orkspace', _ = 'which_key_ignore' },
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
'folke/which-key.nvim',
|
||||||
|
init = init,
|
||||||
|
config = config,
|
||||||
|
event = "VeryLazy",
|
||||||
|
}
|
Loading…
Reference in New Issue