diff --git a/lua/plugins/10-editor.lua b/lua/plugins/10-editor.lua index c481814..168c300 100644 --- a/lua/plugins/10-editor.lua +++ b/lua/plugins/10-editor.lua @@ -1,11 +1,3 @@ -function lualine_my_location() - local line = vim.fn.line('.') - local line_cnt = vim.fn.line('$') - local col = vim.fn.virtcol('.') - local col_cnt = vim.fn.virtcol('$') - 1 - return string.format('%3d(%d):%d(%d)', line, line_cnt, col, col_cnt) -end - return { { "sainnhe/gruvbox-material", @@ -34,106 +26,4 @@ return { event = "VeryLazy", opts = { }, }, - { - "akinsho/bufferline.nvim", - enabled = custom.full_feature, - main = "bufferline", - event = "VeryLazy", - keys = { - { "zn", "BufferLineCycleNext" }, - { "zp", "BufferLineCyclePrev" }, - { "zcn", "BufferLineMoveNext" }, - { "zcp", "BufferLineMovePrev" }, - }, - opts = { - options = { - numbers = "ordinal", - diagnostics = "nvim_lsp", - diagnostics_indicator = function(count, level, diagnostics_dict, context) - local icon = level:match("error") and " " or " " - return " " .. icon .. count - end, - separator_style = "thick", - offsets = { - { - filetype = "NvimTree", - text = "Nvim Tree", - text_align = "center", - separator = true, - }, - }, - persist_buffer_sort = false, - } - }, - }, - { - "nvim-lualine/lualine.nvim", - enabled = custom.full_feature, - dependencies = { - "nvim-tree/nvim-web-devicons" - }, - main = "lualine", - event = "VeryLazy", - opts = { - sections = { - lualine_a = {'mode'}, - lualine_b = {'branch', 'diff', 'diagnostics'}, - lualine_c = {'filename'}, - lualine_x = {'encoding', 'fileformat', 'filetype'}, - lualine_y = {'progress'}, - lualine_z = { lualine_my_location }, - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = {'filename'}, - lualine_x = {'encoding', 'fileformat', 'filetype'}, - lualine_y = {'progress'}, - lualine_z = { lualine_my_location }, - } - }, - init = function(_) - vim.o.mousemoveevent = true - end, - }, - { - "nvim-tree/nvim-tree.lua", - enabled = custom.full_feature, - dependencies = { - "nvim-tree/nvim-web-devicons" - }, - main = "nvim-tree", - event = "VeryLazy", - opts = { - filters = { - git_ignored = false, - }, - }, - keys = { - { "t", "NvimTreeFocus", mode = "n" }, - { "f", "NvimTreeFindFile", mode = "n" }, - }, - init = function(_) - vim.g.loaded_netrw = 1 - vim.g.loaded_netrwPlugin = 1 - - vim.api.nvim_create_autocmd("QuitPre", { - callback = function() - local invalid_win = {} - local wins = vim.api.nvim_list_wins() - for _, w in ipairs(wins) do - local bufname = vim.api.nvim_buf_get_name(vim.api.nvim_win_get_buf(w)) - if bufname:match("NvimTree_") ~= nil then - table.insert(invalid_win, w) - end - end - if #invalid_win == #wins - 1 then - -- Should quit, so we close all invalid windows. - for _, w in ipairs(invalid_win) do vim.api.nvim_win_close(w, true) end - end - end - }) - end, - } } - diff --git a/lua/plugins/13-lines.lua b/lua/plugins/13-lines.lua new file mode 100644 index 0000000..7189df3 --- /dev/null +++ b/lua/plugins/13-lines.lua @@ -0,0 +1,78 @@ +local function my_location() + local line = vim.fn.line('.') + local line_cnt = vim.fn.line('$') + local col = vim.fn.virtcol('.') + local col_cnt = vim.fn.virtcol('$') - 1 + return string.format('%3d(%d):%d(%d)', line, line_cnt, col, col_cnt) +end + +return { + { + "akinsho/bufferline.nvim", + enabled = custom.full_feature, + main = "bufferline", + event = "VeryLazy", + keys = { + { "zn", "BufferLineCycleNext" }, + { "zp", "BufferLineCyclePrev" }, + { "zcn", "BufferLineMoveNext" }, + { "zcp", "BufferLineMovePrev" }, + }, + opts = { + options = { + numbers = "ordinal", + diagnostics = "nvim_lsp", + diagnostics_indicator = function(count, level, diagnostics_dict, context) + local icon = level:match("error") and " " or " " + return " " .. icon .. count + end, + separator_style = "thick", + offsets = { + { + filetype = "NvimTree", + text = "Nvim Tree", + text_align = "center", + separator = true, + }, + }, + persist_buffer_sort = false, + } + }, + }, + { + "nvim-lualine/lualine.nvim", + enabled = custom.full_feature, + dependencies = { + "nvim-tree/nvim-web-devicons" + }, + main = "lualine", + event = "VeryLazy", + opts = { + sections = { + lualine_a = { 'mode' }, + lualine_b = { 'branch', 'diff', 'diagnostics' }, + lualine_c = { 'filename' }, + lualine_x = { 'encoding' , 'fileformat', 'filetype' }, + lualine_y = { 'progress' }, + lualine_z = { my_location }, + }, + inactive_sections = { + lualine_a = { }, + lualine_b = { }, + lualine_c = { 'filename' }, + lualine_x = { 'encoding', 'fileformat', 'filetype' }, + lualine_y = { 'progress' }, + lualine_z = { my_location }, + }, + options = { + disabled_filetypes = { + statusline = {'NvimTree'}, + winbar = {}, + }, + }, + }, + init = function(_) + vim.o.mousemoveevent = true + end, + }, +} diff --git a/lua/plugins/15-tree.lua b/lua/plugins/15-tree.lua new file mode 100644 index 0000000..aa8a193 --- /dev/null +++ b/lua/plugins/15-tree.lua @@ -0,0 +1,41 @@ +return{ + { + "nvim-tree/nvim-tree.lua", + enabled = custom.full_feature, + dependencies = { + "nvim-tree/nvim-web-devicons" + }, + main = "nvim-tree", + event = "VeryLazy", + opts = { + filters = { + git_ignored = false, + }, + }, + keys = { + { "t", "NvimTreeFocus", mode = "n" }, + { "f", "NvimTreeFindFile", mode = "n" }, + }, + init = function(_) + vim.g.loaded_netrw = 1 + vim.g.loaded_netrwPlugin = 1 + + vim.api.nvim_create_autocmd("QuitPre", { + callback = function() + local invalid_win = {} + local wins = vim.api.nvim_list_wins() + for _, w in ipairs(wins) do + local bufname = vim.api.nvim_buf_get_name(vim.api.nvim_win_get_buf(w)) + if bufname:match("NvimTree_") ~= nil then + table.insert(invalid_win, w) + end + end + if #invalid_win == #wins - 1 then + -- Should quit, so we close all invalid windows. + for _, w in ipairs(invalid_win) do vim.api.nvim_win_close(w, true) end + end + end + }) + end, + }, +}