diff --git a/init.lua b/init.lua index 093185f0..b83959a9 100644 --- a/init.lua +++ b/init.lua @@ -132,6 +132,40 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then end ---@diagnostic disable-next-line: undefined-field vim.opt.rtp:prepend(lazypath) +local floating_win = nil + +function FloatingTerm() + if floating_win and vim.api.nvim_win_is_valid(floating_win) then + vim.api.nvim_win_close(floating_win, true) + floating_win = nil + return + end + + local buf = vim.api.nvim_create_buf(false, true) + local width = math.floor(vim.o.columns * 0.8) + local height = math.floor(vim.o.lines * 0.8) + local row = math.floor((vim.o.lines - height) / 2) + local col = math.floor((vim.o.columns - width) / 2) + + floating_win = vim.api.nvim_open_win(buf, true, { + relative = 'editor', + width = width, + height = height, + row = row, + col = col, + style = 'minimal', + border = 'rounded', + }) + + vim.fn.termopen(vim.o.shell) + vim.cmd 'startinsert' + + -- Map to close the floating terminal when inside it + vim.api.nvim_buf_set_keymap(buf, 't', '', ':lua FloatingTerm()', { noremap = true, silent = true }) +end + +vim.api.nvim_set_keymap('n', 't', ':lua FloatingTerm()', { noremap = true, silent = true }) + require('lazy').setup({ { import = 'custom.plugins' } }, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the diff --git a/lua/custom/plugins/conform.lua b/lua/custom/plugins/conform.lua index ed1ad913..dff388b2 100644 --- a/lua/custom/plugins/conform.lua +++ b/lua/custom/plugins/conform.lua @@ -31,11 +31,11 @@ return { -- Autoformat } end, formatters_by_ft = { + java = { 'google-java-format' }, + terraform = { 'terraform_fmt' }, + xml = { 'xmlformatter', 'prettier' }, lua = { 'stylua' }, - -- Conform can also run multiple formatters sequentially python = { 'isort', 'black' }, - -- - -- You can use 'stop_after_first' to run the first available formatter from the list javascript = { 'prettierd', 'prettier', stop_after_first = true }, }, }, diff --git a/lua/custom/plugins/copilot.lua b/lua/custom/plugins/copilot.lua new file mode 100644 index 00000000..36857ada --- /dev/null +++ b/lua/custom/plugins/copilot.lua @@ -0,0 +1,7 @@ +return { + 'github/copilot.vim', + config = function() + vim.keymap.set('i', '', 'copilot#Accept("\\")', { expr = true, replace_keycodes = false }) + vim.g.copilot_no_tab_map = true + end, +} diff --git a/lua/custom/plugins/glow.lua b/lua/custom/plugins/glow.lua new file mode 100644 index 00000000..be576e3d --- /dev/null +++ b/lua/custom/plugins/glow.lua @@ -0,0 +1,6 @@ +return { + 'ellisonleao/glow.nvim', + config = function() + require('glow').setup() + end, +} diff --git a/lua/custom/plugins/illuminate.lua b/lua/custom/plugins/illuminate.lua index 0b61eff5..1dd406d5 100644 --- a/lua/custom/plugins/illuminate.lua +++ b/lua/custom/plugins/illuminate.lua @@ -1,33 +1,33 @@ return { - 'RRethy/vim-illuminate', - event = 'VeryLazy', - config = function() - require('illuminate').configure { - providers = { - 'lsp', - 'treesitter', - 'regex', - }, - delay = 100, - filetype_overrides = {}, - filetypes_denylist = { - 'dirbuf', - 'dirvish', - 'fugitive', - }, - filetypes_allowlist = {}, - modes_denylist = {}, - modes_allowlist = {}, - providers_regex_syntax_denylist = {}, - providers_regex_syntax_allowlist = {}, - under_cursor = true, - large_file_cutoff = nil, - large_file_overrides = nil, - min_count_to_highlight = 1, - should_enable = function(_) - return true - end, - case_insensitive_regex = false, - } - end, + -- 'RRethy/vim-illuminate', + -- event = 'VeryLazy', + -- config = function() + -- require('illuminate').configure { + -- providers = { + -- 'lsp', + -- 'treesitter', + -- 'regex', + -- }, + -- delay = 100, + -- filetype_overrides = {}, + -- filetypes_denylist = { + -- 'dirbuf', + -- 'dirvish', + -- 'fugitive', + -- }, + -- filetypes_allowlist = {}, + -- modes_denylist = {}, + -- modes_allowlist = {}, + -- providers_regex_syntax_denylist = {}, + -- providers_regex_syntax_allowlist = {}, + -- under_cursor = true, + -- large_file_cutoff = nil, + -- large_file_overrides = nil, + -- min_count_to_highlight = 1, + -- should_enable = function(_) + -- return true + -- end, + -- case_insensitive_regex = false, + -- } + -- end, } diff --git a/lua/custom/plugins/lint.lua b/lua/custom/plugins/lint.lua index b4218fa0..e057edae 100644 --- a/lua/custom/plugins/lint.lua +++ b/lua/custom/plugins/lint.lua @@ -4,7 +4,7 @@ return { config = function() local lint = require 'lint' lint.linters_by_ft = { - markdown = { 'markdownlint' }, + markdown = { 'vale' }, } -- To allow other plugins to add linters to require('lint').linters_by_ft, diff --git a/lua/custom/plugins/markdown-preview.lua b/lua/custom/plugins/markdown-preview.lua new file mode 100644 index 00000000..b570bb80 --- /dev/null +++ b/lua/custom/plugins/markdown-preview.lua @@ -0,0 +1,7 @@ +return { + 'iamcco/markdown-preview.nvim', + build = 'cd app && npm install', + config = function() + vim.g.mkdp_auto_start = 1 + end, +} diff --git a/lua/custom/plugins/mini.lua b/lua/custom/plugins/mini.lua index b5ac322f..f6b60e32 100644 --- a/lua/custom/plugins/mini.lua +++ b/lua/custom/plugins/mini.lua @@ -5,6 +5,7 @@ return { -- Collection of various small independent plugins/modules require('mini.move').setup() require('mini.notify').setup() require('mini.starter').setup() + require('mini.tabline').setup() require('mini.statusline').setup { use_icons = vim.g.have_nerd_font, } diff --git a/lua/custom/plugins/neo-tree.lua b/lua/custom/plugins/neo-tree.lua index a1951eb7..7d4ed26c 100644 --- a/lua/custom/plugins/neo-tree.lua +++ b/lua/custom/plugins/neo-tree.lua @@ -3,22 +3,151 @@ return { version = '*', dependencies = { 'nvim-lua/plenary.nvim', - 'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended + 'nvim-tree/nvim-web-devicons', 'MunifTanjim/nui.nvim', + 'saifulapm/neotree-file-nesting-config', }, cmd = 'Neotree', - keys = { - { '\\', ':Neotree reveal', desc = 'NeoTree reveal', silent = true }, - }, opts = { + -- recommended config for better UI + hide_root_node = true, + retain_hidden_root_indent = true, filesystem = { - window = { - mappings = { - ['\\'] = 'close_window', - [''] = { 'toggle_node', nowait = true }, - ['P'] = { 'toggle_preview', config = { use_float = false } }, + filtered_items = { + show_hidden_count = false, + never_show = { + '.DS_Store', }, }, }, + default_component_configs = { + indent = { + with_expanders = true, + expander_collapsed = '', + expander_expanded = '', + }, + }, }, + keys = { + { '\\', ':Neotree reveal', desc = 'NeoTree reveal', silent = true }, + { + 'b', + function() + require('neo-tree.command').execute { toggle = true, source = 'buffers', position = 'left' } + end, + desc = 'Buffers (root dir)', + }, + { + 'e', + function() + require('neo-tree.command').execute { toggle = true, source = 'filesystem', position = 'left' } + end, + desc = 'Filesystem (root dir)', + }, + { + 'g', + function() + require('neo-tree.command').execute { toggle = true, source = 'git_status', position = 'left' } + end, + desc = 'Filesystem (root dir)', + }, + }, + config = function(_, opts) + opts.nesting_rules = require('neotree-file-nesting-config').nesting_rules + require('neo-tree').setup(opts) + + local inputs = require 'neo-tree.ui.inputs' + -- Trash the target + local function trash(state) + local node = state.tree:get_node() + if node.type == 'message' then + return + end + local _, name = require('neo-tree.utils').split_path(node.path) + local msg = string.format("Are you sure you want to trash '%s'?", name) + inputs.confirm(msg, function(confirmed) + if not confirmed then + return + end + vim.api.nvim_command('silent !trash -F ' .. node.path) + require('neo-tree.sources.manager').refresh(state) + end) + end + + -- Trash the selections (visual mode) + local function trash_visual(state, selected_nodes) + local paths_to_trash = {} + for _, node in ipairs(selected_nodes) do + if node.type ~= 'message' then + table.insert(paths_to_trash, node.path) + end + end + local msg = 'Are you sure you want to trash ' .. #paths_to_trash .. ' items?' + inputs.confirm(msg, function(confirmed) + if not confirmed then + return + end + for _, path in ipairs(paths_to_trash) do + vim.api.nvim_command('silent !trash -F ' .. path) + end + require('neo-tree.sources.manager').refresh(state) + end) + end + + require('neo-tree').setup { + event_handlers = { + { + event = 'neo_tree_buffer_enter', + handler = function() + vim.cmd 'highlight! Cursor blend=100' + end, + }, + { + event = 'neo_tree_buffer_leave', + handler = function() + vim.cmd 'highlight! Cursor guibg=#5f87af blend=0' + end, + }, + }, + window = { + mappings = { + ['T'] = 'trash', + ['h'] = function(state) + local node = state.tree:get_node() + if node.type == 'directory' and node:is_expanded() then + require('neo-tree.sources.filesystem').toggle_directory(state, node) + else + require('neo-tree.ui.renderer').focus_node(state, node:get_parent_id()) + end + end, + ['l'] = function(state) + local node = state.tree:get_node() + if node.type == 'directory' then + if not node:is_expanded() then + require('neo-tree.sources.filesystem').toggle_directory(state, node) + elseif node:has_children() then + require('neo-tree.ui.renderer').focus_node(state, node:get_child_ids()[1]) + end + else + state.commands['open'](state) + vim.cmd 'Neotree reveal' + end + end, + [''] = function(state) + local node = state.tree:get_node() + if require('neo-tree.utils').is_expandable(node) then + state.commands['toggle_node'](state) + else + state.commands['open'](state) + vim.cmd 'Neotree reveal' + end + end, + }, + }, + commands = { + trash = trash, + trash_visual = trash_visual, + }, + } + end, } diff --git a/lua/custom/plugins/treesitter.lua b/lua/custom/plugins/treesitter.lua index d330f6da..1c2ba53a 100644 --- a/lua/custom/plugins/treesitter.lua +++ b/lua/custom/plugins/treesitter.lua @@ -21,6 +21,14 @@ return { -- Highlight, edit, and navigate code 'query', 'vim', 'vimdoc', + 'java', + 'json', + 'markdown', + 'nginx', + 'sql', + 'tmux', + 'typescript', + 'yaml', }, -- Autoinstall languages that are not installed auto_install = true,