diff --git a/dot_config/nvim/lua/core/config.lua b/dot_config/nvim/lua/core/config.lua index f77c55b..3eff738 100644 --- a/dot_config/nvim/lua/core/config.lua +++ b/dot_config/nvim/lua/core/config.lua @@ -31,8 +31,8 @@ vim.opt.list = true vim.opt.smartcase = true vim.opt.wrap = false vim.opt.whichwrap:append { - ['<'] = true, - ['>'] = true, - ['['] = true, - [']'] = true, + ['<'] = true, + ['>'] = true, + ['['] = true, + [']'] = true, } diff --git a/dot_config/nvim/lua/plugins/autocompletion.lua b/dot_config/nvim/lua/plugins/autocompletion.lua index eaf283a..e1ad2a0 100644 --- a/dot_config/nvim/lua/plugins/autocompletion.lua +++ b/dot_config/nvim/lua/plugins/autocompletion.lua @@ -1,61 +1,61 @@ local function config() - local cmp = require 'cmp' - local luasnip = require 'luasnip' + local cmp = require 'cmp' + local luasnip = require 'luasnip' - local function expand(args) - luasnip.lsp_expand(args.body) - end + local function expand(args) + luasnip.lsp_expand(args.body) + end - local function tab_mapping(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end + local function tab_mapping(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end - local function back_tab_mapping(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end + local function back_tab_mapping(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end - cmp.setup { - enabled = true, + cmp.setup { + enabled = true, - snippet = { expand = expand }, - sources = { - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - }, + snippet = { expand = expand }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, - mapping = cmp.mapping.preset.insert { - [''] = cmp.mapping.select_next_item(), - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete({}), - [''] = cmp.mapping(tab_mapping, { 'i', 's' }), - [''] = cmp.mapping(back_tab_mapping, { 'i', 's' }), - [''] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }, - }, - } + mapping = cmp.mapping.preset.insert { + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete({}), + [''] = cmp.mapping(tab_mapping, { 'i', 's' }), + [''] = cmp.mapping(back_tab_mapping, { 'i', 's' }), + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + }, + } end return { - 'hrsh7th/nvim-cmp', - config = config, - dependencies = { - 'saadparwaiz1/cmp_luasnip', - 'hrsh7th/cmp-nvim-lsp', - }, + 'hrsh7th/nvim-cmp', + config = config, + dependencies = { + 'saadparwaiz1/cmp_luasnip', + 'hrsh7th/cmp-nvim-lsp', + }, } diff --git a/dot_config/nvim/lua/plugins/base.lua b/dot_config/nvim/lua/plugins/base.lua index be12771..472ad01 100644 --- a/dot_config/nvim/lua/plugins/base.lua +++ b/dot_config/nvim/lua/plugins/base.lua @@ -1,22 +1,7 @@ -local config = function() - local wk = require 'which-key' - wk.setup() - wk.register { - ['c'] = { name = '[C]ode', _ = 'which_key_ignore' }, - ['d'] = { name = '[D]ocument', _ = 'which_key_ignore' }, - ['g'] = { name = '[G]it', _ = 'which_key_ignore' }, - ['h'] = { name = 'More git', _ = 'which_key_ignore' }, - ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, - ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, - ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, - } -end - return { - 'folke/which-key.nvim', - config = config, - dependencies = { - { 'tpope/vim-sleuth', tag = 'v2.0' }, - { 'tpope/vim-surround', tag = 'v2.2' }, - }, + 'tpope/vim-surround', + tag = 'v2.2', + dependencies = { + { 'tpope/vim-sleuth', tag = 'v2.0' }, + }, } diff --git a/dot_config/nvim/lua/plugins/lsp.lua b/dot_config/nvim/lua/plugins/lsp.lua deleted file mode 100644 index 5be18a9..0000000 --- a/dot_config/nvim/lua/plugins/lsp.lua +++ /dev/null @@ -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('rn', vim.lsp.buf.rename, '[R]e[n]ame') - nmap('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('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') - nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') - nmap('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('', vim.lsp.buf.signature_help, 'Signature Documentation') - - -- Lesser used LSP functionality - nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') - nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') - nmap('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', - }, -} diff --git a/dot_config/nvim/lua/plugins/lsp.lua.tmpl b/dot_config/nvim/lua/plugins/lsp.lua.tmpl new file mode 100644 index 0000000..7dd184c --- /dev/null +++ b/dot_config/nvim/lua/plugins/lsp.lua.tmpl @@ -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('rn', vim.lsp.buf.rename, '[R]e[n]ame') + nmap('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('D', builtin.lsp_type_definitions, 'Type [D]efinition') + nmap('ds', builtin.lsp_document_symbols, '[D]ocument [S]ymbols') + nmap('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('', vim.lsp.buf.signature_help, 'Signature Documentation') + + -- Lesser used LSP functionality + nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') + nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') + nmap('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.*' }, + }, +} diff --git a/dot_config/nvim/lua/plugins/snippets.lua b/dot_config/nvim/lua/plugins/snippets.lua index a708593..42e1511 100644 --- a/dot_config/nvim/lua/plugins/snippets.lua +++ b/dot_config/nvim/lua/plugins/snippets.lua @@ -1,12 +1,12 @@ local function config() - local luasnip = require 'luasnip' - luasnip.setup() - luasnip.config.setup({}) + local luasnip = require 'luasnip' + luasnip.setup() + luasnip.config.setup({}) end return { - 'L3MON4D3/LuaSnip', - config = config, - tag = 'v2.*', - dependencies = {}, + 'L3MON4D3/LuaSnip', + config = config, + tag = 'v2.*', + dependencies = {}, } diff --git a/dot_config/nvim/lua/plugins/telescope.lua b/dot_config/nvim/lua/plugins/telescope.lua index 56d707c..4769199 100644 --- a/dot_config/nvim/lua/plugins/telescope.lua +++ b/dot_config/nvim/lua/plugins/telescope.lua @@ -1,97 +1,97 @@ -- 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 + -- 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 + -- 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 -- Custom live_grep function to search in git root local function live_grep_git_root() - local git_root = find_git_root() - if git_root then - require('telescope.builtin').live_grep({ - search_dirs = { git_root }, - }) - end + local git_root = find_git_root() + if git_root then + require('telescope.builtin').live_grep({ + search_dirs = { git_root }, + }) + end end vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {}) local telescope_setup = { - defaults = { - mappings = { - i = { - [''] = false, - [''] = false, - }, - }, - }, + defaults = { + mappings = { + i = { + [''] = false, + [''] = false, + }, + }, + }, } local function config() - -- See `:help telescope` and `:help telescope.setup()` - local telescope = require('telescope') - local builtin = require('telescope.builtin') - local themes = require('telescope.themes') + -- See `:help telescope` and `:help telescope.setup()` + local telescope = require('telescope') + local builtin = require('telescope.builtin') + local themes = require('telescope.themes') - telescope.setup(telescope_setup) + telescope.setup(telescope_setup) - -- Enable telescope fzf native, if installed - pcall(telescope.load_extension, 'fzf') + -- Enable telescope fzf native, if installed + pcall(telescope.load_extension, 'fzf') - local fuzzy_find = function() - -- You can pass additional configuration to telescope to change theme, layout, etc. - builtin.current_buffer_fuzzy_find(themes.get_dropdown({ - winblend = 10, - previewer = false, - })) - end + local fuzzy_find = function() + -- You can pass additional configuration to telescope to change theme, layout, etc. + builtin.current_buffer_fuzzy_find(themes.get_dropdown({ + winblend = 10, + previewer = false, + })) + end - -- See `:help telescope.builtin` - vim.keymap.set('n', '?', builtin.oldfiles, { desc = '[?] Find recently opened files' }) - vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) - vim.keymap.set('n', '/', fuzzy_find, { desc = '[/] Fuzzily search in current buffer' }) - vim.keymap.set('n', 'gf', builtin.git_files, { desc = 'Search [G]it [F]iles' }) - vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) - vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) - vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) - vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) - vim.keymap.set('n', 'sG', live_grep_git_root, { desc = '[S]earch by [G]rep on Git Root' }) - vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) - vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) + -- See `:help telescope.builtin` + vim.keymap.set('n', '?', builtin.oldfiles, { desc = '[?] Find recently opened files' }) + vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) + vim.keymap.set('n', '/', fuzzy_find, { desc = '[/] Fuzzily search in current buffer' }) + vim.keymap.set('n', 'gf', builtin.git_files, { desc = 'Search [G]it [F]iles' }) + vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) + vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) + vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) + vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) + vim.keymap.set('n', 'sG', live_grep_git_root, { desc = '[S]earch by [G]rep on Git Root' }) + vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) + vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) end local is_make_installed = function() - return vim.fn.executable('make') == 1 + return vim.fn.executable('make') == 1 end return { - 'nvim-telescope/telescope.nvim', - branch = '0.1.x', - config = config, - dependencies = { - 'nvim-lua/plenary.nvim', - { - 'nvim-telescope/telescope-fzf-native.nvim', - cond = is_make_installed, - build = 'make', - }, - }, + 'nvim-telescope/telescope.nvim', + branch = '0.1.x', + config = config, + dependencies = { + 'nvim-lua/plenary.nvim', + { + 'nvim-telescope/telescope-fzf-native.nvim', + cond = is_make_installed, + build = 'make', + }, + }, } diff --git a/dot_config/nvim/lua/plugins/theme.lua b/dot_config/nvim/lua/plugins/theme.lua index 5e4282f..d5a3f1b 100644 --- a/dot_config/nvim/lua/plugins/theme.lua +++ b/dot_config/nvim/lua/plugins/theme.lua @@ -1,17 +1,17 @@ local function config() - vim.cmd.colorscheme 'gruvbox' + vim.cmd.colorscheme 'gruvbox' end return { - 'morhetz/gruvbox', - priority = 1000, - config = config, - dependencies = { - 'nvim-lualine/lualine.nvim', - opts = { - options = { - theme = 'gruvbox', - }, - }, - }, + 'morhetz/gruvbox', + priority = 1000, + config = config, + dependencies = { + 'nvim-lualine/lualine.nvim', + opts = { + options = { + theme = 'gruvbox', + }, + }, + }, } diff --git a/dot_config/nvim/lua/plugins/tree.lua b/dot_config/nvim/lua/plugins/tree.lua index fff5f15..331572a 100644 --- a/dot_config/nvim/lua/plugins/tree.lua +++ b/dot_config/nvim/lua/plugins/tree.lua @@ -3,58 +3,58 @@ vim.g.loaded_netrwPlugin = 1 vim.opt.termguicolors = true local function handle_closed(window) - local tab = vim.api.nvim_win_get_tabpage(window) - local buffer = vim.api.nvim_win_get_buf(window) - local info = vim.fn.getbufinfo(buffer)[1] - - local filter_window = function(w) - return w ~= window - end - - 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) - - if info.name:match('.*NvimTree_%d*$') then - if not vim.tbl_isempty(buffers) then - require('nvim-tree.api').tree.close() - end - return - end - - if #buffers ~= 1 then - return - end - - local last_info = vim.fn.getbufinfo(buffers[1])[1] - if last_info.name:match('.*NvimTree_%d*$') then - vim.schedule(function() - if #vim.api.nvim_list_wins() == 1 then - vim.cmd 'quit' - else - vim.api.nvim_win_close(windows[1], true) - end - end) - end + local tab = vim.api.nvim_win_get_tabpage(window) + local buffer = vim.api.nvim_win_get_buf(window) + local info = vim.fn.getbufinfo(buffer)[1] + + local function filter_window(w) + return w ~= window + end + + 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) + + if info.name:match('.*NvimTree_%d*$') then + if not vim.tbl_isempty(buffers) then + require('nvim-tree.api').tree.close() + end + return + end + + if #buffers ~= 1 then + return + end + + local last_info = vim.fn.getbufinfo(buffers[1])[1] + if last_info.name:match('.*NvimTree_%d*$') then + vim.schedule(function() + if #vim.api.nvim_list_wins() == 1 then + vim.cmd 'quit' + else + vim.api.nvim_win_close(windows[1], true) + end + end) + end end -local config = function() - require('nvim-tree').setup() - vim.api.nvim_create_autocmd('WinClosed', { - nested = true, - callback = function() - local window = tonumber(vim.fn.expand('')) - vim.schedule_wrap(handle_closed(window)) - end, - }) +local function config() + require('nvim-tree').setup() + vim.api.nvim_create_autocmd('WinClosed', { + nested = true, + callback = function() + local window = tonumber(vim.fn.expand('')) + handle_closed(window) + end, + }) end return { - 'nvim-tree/nvim-tree.lua', - config = config, - keys = { - { 'nt', ':NvimTreeToggle', desc = 'toggle nvim tree' } - }, - dependencies = { - 'nvim-tree/nvim-web-devicons', opts = {} - }, + 'nvim-tree/nvim-tree.lua', + config = config, + keys = { + { 'nt', ':NvimTreeToggle', desc = 'toggle nvim tree' } + }, + dependencies = { + 'nvim-tree/nvim-web-devicons', opts = {} + }, } diff --git a/dot_config/nvim/lua/plugins/treesitter.lua b/dot_config/nvim/lua/plugins/treesitter.lua index f9092a0..4a3e32c 100644 --- a/dot_config/nvim/lua/plugins/treesitter.lua +++ b/dot_config/nvim/lua/plugins/treesitter.lua @@ -1,93 +1,93 @@ local treesitter_config_setup = { - -- Add languages to be installed here that you want installed for treesitter - ensure_installed = { - 'bash', 'c', 'cpp', 'go', 'lua', 'python', 'rust', - 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim', - }, + -- Add languages to be installed here that you want installed for treesitter + ensure_installed = { + 'bash', 'c', 'cpp', 'go', 'lua', 'python', 'rust', + 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim', + }, - auto_install = true, - sync_install = false, + auto_install = true, + sync_install = false, - modules = {}, - ignore_install = {}, + modules = {}, + ignore_install = {}, - highlight = { enable = true }, - indent = { enable = true }, + highlight = { enable = true }, + indent = { enable = true }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = '', - node_incremental = '', - scope_incremental = '', - node_decremental = '', - }, - }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + node_incremental = '', + scope_incremental = '', + node_decremental = '', + }, + }, - textobjects = { - select = { - enable = true, - -- Automatically jump forward to textobj, similar to targets.vim - lookahead = true, - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ['aa'] = '@parameter.outer', - ['ia'] = '@parameter.inner', - ['af'] = '@function.outer', - ['if'] = '@function.inner', - ['ac'] = '@class.outer', - ['ic'] = '@class.inner', - }, - }, + textobjects = { + select = { + enable = true, + -- Automatically jump forward to textobj, similar to targets.vim + lookahead = true, + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ['aa'] = '@parameter.outer', + ['ia'] = '@parameter.inner', + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + }, + }, - swap = { - enable = true, - swap_next = { - ['a'] = '@parameter.inner', - }, - swap_previous = { - ['A'] = '@parameter.inner', - }, - }, + swap = { + enable = true, + swap_next = { + ['a'] = '@parameter.inner', + }, + swap_previous = { + ['A'] = '@parameter.inner', + }, + }, - move = { - enable = true, - -- whether to set jumps in the jumplist - set_jumps = true, - goto_next_start = { - [']m'] = '@function.outer', - [']]'] = '@class.outer', - }, - goto_next_end = { - [']M'] = '@function.outer', - [']['] = '@class.outer', - }, - goto_previous_start = { - ['[m'] = '@function.outer', - ['[['] = '@class.outer', - }, - goto_previous_end = { - ['[M'] = '@function.outer', - ['[]'] = '@class.outer', - }, - }, - }, + move = { + enable = true, + -- whether to set jumps in the jumplist + set_jumps = true, + goto_next_start = { + [']m'] = '@function.outer', + [']]'] = '@class.outer', + }, + goto_next_end = { + [']M'] = '@function.outer', + [']['] = '@class.outer', + }, + goto_previous_start = { + ['[m'] = '@function.outer', + ['[['] = '@class.outer', + }, + goto_previous_end = { + ['[M'] = '@function.outer', + ['[]'] = '@class.outer', + }, + }, + }, } local function treesitter_configs() - require('nvim-treesitter.configs').setup(treesitter_config_setup) + require('nvim-treesitter.configs').setup(treesitter_config_setup) end local function config() - vim.defer_fn(treesitter_configs, 0) + vim.defer_fn(treesitter_configs, 0) end return { - -- Highlight, edit, and navigate code - 'nvim-treesitter/nvim-treesitter', - config = config, - build = ':TSUpdate', - dependencies = { - 'nvim-treesitter/nvim-treesitter-textobjects', - }, + -- Highlight, edit, and navigate code + 'nvim-treesitter/nvim-treesitter', + config = config, + build = ':TSUpdate', + dependencies = { + 'nvim-treesitter/nvim-treesitter-textobjects', + }, } diff --git a/dot_config/nvim/lua/plugins/which-key.lua b/dot_config/nvim/lua/plugins/which-key.lua new file mode 100644 index 0000000..4ba45cc --- /dev/null +++ b/dot_config/nvim/lua/plugins/which-key.lua @@ -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 { + ['c'] = { name = '[C]ode', _ = 'which_key_ignore' }, + ['d'] = { name = '[D]ocument', _ = 'which_key_ignore' }, + ['g'] = { name = '[G]it', _ = 'which_key_ignore' }, + ['h'] = { name = 'More git', _ = 'which_key_ignore' }, + ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, + ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, + ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, + } +end + +return { + 'folke/which-key.nvim', + init = init, + config = config, + event = "VeryLazy", +} diff --git a/dot_editorconfig b/dot_editorconfig index 209cfd6..0c6c5b1 100644 --- a/dot_editorconfig +++ b/dot_editorconfig @@ -15,6 +15,6 @@ indent_style = tab indent_size = 4 indent_style = space -[*.{json,yml,yaml}] +[*.{json,yml,yaml,lua}] indent_style = space indent_size = 2