diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 977e6d9..1ee68d2 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -32,6 +32,7 @@ require('feline').setup { force_inactive = { filetypes = { '^neo\\-tree$', + '^aerial$', '^packer$', '^startify$', '^fugitive$', @@ -55,7 +56,13 @@ require('lspconfig/settings') require('window-picker').setup({ autoselect_one = true, - selection_chars = 'ABCDEFGHIJKLMNOP' + selection_chars = 'ABCDEFGHIJKLMNOP', + filter_rules = { + bo = { + filetype = { 'NvimTree', "neo-tree", "notify", 'aerial' }, + buftype = { 'terminal' } + } + } }) vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]]) @@ -65,6 +72,8 @@ require('neo-tree').setup({ width = 30, mappings = { [""] = "open_with_window_picker", + ["S"] = "split_with_window_picker", + ["s"] = "vsplit_with_window_picker" } }, filesystem = { @@ -74,11 +83,15 @@ require('neo-tree').setup({ follow_current_file = true,window = { mappings = { ["/"] = "noop", - ["g/"] = "fuzzy_finder" + ["g/"] = "fuzzy_finder", + ["f"] = "noop", + ["ff"] = function() vim.cmd([[Telescope find_files]]) end, + ["fg"] = function() vim.cmd([[Telescope live_grep]]) end } } } }) +vim.keymap.set("n", "f", "Neotree focus", opts) require('smart-splits') @@ -100,7 +113,10 @@ require('bufferline').setup{ options = { close_command = "Bdelete %d", right_mouse_command = "Bdelete %d", - offsets = {{filetype = "neo-tree", text = "File Explorer", padding = 1}}, + offsets = { + {filetype = "neo-tree", text = "File Explorer", padding = 1}, + {filetype = "aerial", text = "Outline", padding = 1} + }, enforce_regular_tabs = true, separator_style = 'slant' }, @@ -121,12 +137,61 @@ vim.keymap.set("n", "", "bprevious", opts) vim.keymap.set("n", "q", "Bdelete", opts) -require('nvim-autopairs').setup{} +require('nvim-autopairs').setup() require('gitsigns').setup() +require('cinnamon').setup() + + +require('aerial').setup({ + close_behavior = 'global', + open_automatic = true, + placement_editor_edge = true, + width = 30, + on_attach = function(bufnr) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 't', + require('map_utils').lua_fn(function() + vim.tbl_map(function(buf) + if vim.api.nvim_buf_get_option(buf, 'filetype') == 'aerial' then + vim.tbl_map(function(win) + vim.api.nvim_set_current_win(win) + end, vim.fn.win_findbuf(buf)) + end + end, vim.api.nvim_list_bufs()) + end), + {}) + end +}) + + +require('guess-indent').setup() + + +local actions = require("telescope.actions") +require('telescope').setup({ + defaults = { + mappings = { + n = { + ["S"] = actions.file_split, + ["s"] = actions.file_vsplit, + } + }, + get_selection_window = require('window-picker').pick_window + }, + pickers = { + find_files = { + find_command = {"fd", "--type", "f", "--strip-cwd-prefix", "--hidden"} + }, + live_grep = { + vimgrep_arguments = {"rg", "--color=never", "--no-heading", "--with-filename", "--line-number", "--column", "--smart-case", "--hidden"} + }, + } +}) + + vim.o.clipboard = 'unnamedplus' vim.o.expandtab = true vim.o.fileencoding = 'utf-8' @@ -139,7 +204,6 @@ vim.o.signcolumn = 'yes' vim.o.smartcase = true vim.o.spelllang = 'en' vim.o.tabstop = 2 -vim.o.smartindent = true if vim.fn.expand('%') == '' then diff --git a/.config/nvim/lua/map_utils.lua b/.config/nvim/lua/map_utils.lua new file mode 100644 index 0000000..33a41c4 --- /dev/null +++ b/.config/nvim/lua/map_utils.lua @@ -0,0 +1,34 @@ +local M = {} +local module_name = 'map_utils' +local fn_store = {} + +local function register_fn(fn) + table.insert(fn_store, fn) + return #fn_store +end + +function M.apply_function(id) + fn_store[id]() +end + +function M.apply_expr(id) + return vim.api.nvim_replace_termcodes(fn_store[id](), true, true, true) +end + +function M.lua_fn(fn) + return string.format( + "lua require('%s').apply_function(%s)", + module_name, + register_fn(fn) + ) +end + +function M.lua_expr(fn) + return string.format( + "v:lua.require'%s'.apply_expr(%s)", + module_name, + register_fn(fn) + ) +end + +return M diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index 16269eb..9c39cdd 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -26,14 +26,22 @@ return require('packer').startup(function() } } - use('mrjones2014/smart-splits.nvim') + use 'mrjones2014/smart-splits.nvim' - use('famiu/bufdelete.nvim') + use 'famiu/bufdelete.nvim' use {'akinsho/bufferline.nvim', tag = "v2.*", requires = 'kyazdani42/nvim-web-devicons'} - use('windwp/nvim-autopairs') + use 'windwp/nvim-autopairs' - use('lewis6991/gitsigns.nvim') + use 'lewis6991/gitsigns.nvim' + + use 'declancm/cinnamon.nvim' + + use 'stevearc/aerial.nvim' + + use 'nmac427/guess-indent.nvim' + + use {'nvim-telescope/telescope.nvim', requires = 'nvim-lua/plenary.nvim'} end)