From 44c9268d6753bdc543fa9f2984aeea94af810e0f Mon Sep 17 00:00:00 2001 From: Snoweuph Date: Sun, 15 Dec 2024 06:34:42 +0100 Subject: [PATCH] Medium Sized Config Tweaks --- Readme.md | 3 +- install.sh | 5 +- lua/core/keymap.lua | 14 ++++ lua/editor/dashboard.lua | 141 +++++++++++++++++++++++++++++++++----- lua/editor/sessions.lua | 40 +++++++++++ lua/editor/status_bar.lua | 9 ++- lua/editor/theme.lua | 6 +- lua/toolchain/angular.lua | 52 ++++++++++++++ lua/toolchain/init.lua | 1 + selene.toml | 4 ++ vim.toml | 5 ++ 11 files changed, 253 insertions(+), 27 deletions(-) create mode 100644 lua/editor/sessions.lua create mode 100644 lua/toolchain/angular.lua create mode 100644 selene.toml create mode 100644 vim.toml diff --git a/Readme.md b/Readme.md index 986361d..5306658 100644 --- a/Readme.md +++ b/Readme.md @@ -1 +1,2 @@ -# [Dotfiles](https://git.euph.dev/Snoweuph/Dotfiles)/nvim \ No newline at end of file +# [Dotfiles](https://git.euph.dev/Snoweuph/Dotfiles)/nvim + diff --git a/install.sh b/install.sh index 85a1ecf..6dbcc84 100755 --- a/install.sh +++ b/install.sh @@ -44,6 +44,5 @@ command -v markdownlint &>/dev/null || volta install markdownlint-cli command -v stylelint &>/dev/null || volta install stylelint command -v prettierd &>/dev/null || volta install @fsouza/prettierd - - - +# Angular +command -v ng &>/dev/null || volta install @angular/cli diff --git a/lua/core/keymap.lua b/lua/core/keymap.lua index 14f6212..1e3023d 100644 --- a/lua/core/keymap.lua +++ b/lua/core/keymap.lua @@ -17,6 +17,20 @@ K.FOCUS_SHADE = { }, } +--[[ Sessions ]] +K.SESSIONS = { + CREATE = { + mode = 'n', + shortcut = 'sc', + description = 'Create Session', + }, + MENU = { + mode = "n", + shortcut = 'sm', + description = "Open Session Menu" + } +} + --[[ Git ]] K.GIT = { OPEN = { diff --git a/lua/editor/dashboard.lua b/lua/editor/dashboard.lua index 215160a..cb072da 100644 --- a/lua/editor/dashboard.lua +++ b/lua/editor/dashboard.lua @@ -6,27 +6,132 @@ return { config = function() -- Setup -- local alpha = require('alpha') - local dashboard = require('alpha.themes.startify') + local SECTIONS = {} -- Header -- - dashboard.section.header.val = { - [[ ]], - [[ ]], - [[ ]], - [[ ]], - [[  ]], - [[ ████ ██████ █████ ██ ]], - [[ ███████████ █████  ]], - [[ █████████ ███████████████████ ███ ███████████ ]], - [[ █████████ ███ █████████████ █████ ██████████████ ]], - [[ █████████ ██████████ █████████ █████ █████ ████ █████ ]], - [[ ███████████ ███ ███ █████████ █████ █████ ████ █████ ]], - [[ ██████ █████████████████████ ████ █████ █████ ████ ██████ ]], - [[ ]], - [[ ]], - [[ ]], + SECTIONS.header = { + + type = 'text', + opts = { + position = 'center', + hl = 'DashboardHeader', + }, + val = { + [[ ]], + [[ ]], + [[ ]], + [[ ]], + [[ ██ ]], + [[ ████ ██████ ████ ██ ]], + [[ ███████████ ████ ████  ]], + [[ █████████ ████████ ████ ████ ██ ████████ ]], + [[ █████████ ███ ██████████████ █████ █████████████ ]], + [[ █████████ ██████████ ██████████ █████ █████ ████ ████ ]], + [[ ███████████ ███ ███ ██████████ █████ █████ ████ ████ ]], + [[ ██████ ██████████████████████ █████ █████ █████ ████ ████ ]], + [[ ]], + [[ ]], + [[ ]], + }, } - alpha.setup(dashboard.opts) + SECTIONS.sessions = { + type = 'group', + val = function() + local session_rows = {} + + local session_utils = require('session_manager.utils') + local sessions = session_utils.get_sessions() + table.sort( + sessions, + function(a, b) return a.dir.filename < b.dir.filename end + ) + + local line_len = 0 + for i = 1, #sessions, 1 do + local len = string.len(sessions[i].dir.filename) + if len > line_len then + line_len = len + end + end + + for i = 1, #sessions, 1 do + local session_name = sessions[i].dir.filename + local home_dir = os.getenv('HOME') + session_name = vim.fn.substitute( + session_name, + '^' .. home_dir .. '/Downloads', + '󰇚', + '' + ) + session_name = vim.fn.substitute( + session_name, + '^' .. home_dir .. '/Workspace/Learning', + '󰑴 ', + '' + ) + session_name = vim.fn.substitute( + session_name, + '^' .. home_dir .. '/Workspace/AdventOfCode', + ' ', + '' + ) + session_name = vim.fn.substitute( + session_name, + '^' .. home_dir .. '/Workspace/School', + ' ', + '' + ) + session_name = vim.fn.substitute( + session_name, + '^' .. home_dir .. '/Workspace', + ' ', + '' + ) + session_name = vim.fn.substitute( + session_name, + '^' .. home_dir, + ' ', + '' + ) + + local start_session = function() + session_utils.load_session(sessions[i].filename, false) + end + + local row = { + type = 'button', + val = ' ' .. session_name, + on_press = start_session, + opts = { + keymap = { 'n', tostring(i), start_session }, + shortcut = string.format('[%d]', i), + align_shortcut = 'left', + hl_shortcut = 'DashboardKey', + position = 'center', + cursor = 1, + width = line_len + 5, + }, + } + table.insert(session_rows, row) + end + + return session_rows + end, + } + + local theme = { + layout = { + { type = 'padding', val = 2 }, + SECTIONS.header, + { type = 'padding', val = 2 }, + SECTIONS.sessions, + }, + opts = { + margin = 5, + }, + } + + alpha.setup(theme) end, } diff --git a/lua/editor/sessions.lua b/lua/editor/sessions.lua new file mode 100644 index 0000000..109e8d8 --- /dev/null +++ b/lua/editor/sessions.lua @@ -0,0 +1,40 @@ +local K = require('core.keymap') + +return { + 'shatur/neovim-session-manager', + dependencies = { + 'nvim-lua/plenary.nvim', + }, + config = function() + local Path = require('plenary.path') + local config = require('session_manager.config') + local session_manager = require('session_manager') + session_manager.setup({ + sessions_dir = Path:new(vim.fn.stdpath('data'), 'sessions'), + autoload_mode = config.AutoloadMode.Disabled, + autosave_last_session = true, + autosave_ignore_not_normal = true, + autosave_ignore_dirs = {}, + autosave_ignore_filetypes = { + 'gitcommit', + 'gitrebase', + }, + autosave_ignore_buftypes = {}, + autosave_only_in_session = true, + max_path_length = 80, + }) + + vim.keymap.set( + K.SESSIONS.MENU.mode, + K.SESSIONS.MENU.shortcut, + session_manager.available_commands, + { desc = K.SESSIONS.MENU.description } + ) + vim.keymap.set( + K.SESSIONS.CREATE.mode, + K.SESSIONS.CREATE.shortcut, + session_manager.save_current_session, + { desc = K.SESSIONS.CREATE.description } + ) + end, +} diff --git a/lua/editor/status_bar.lua b/lua/editor/status_bar.lua index 2724ae6..9a710b2 100644 --- a/lua/editor/status_bar.lua +++ b/lua/editor/status_bar.lua @@ -4,10 +4,12 @@ return { dependencies = { 'nvim-tree/nvim-web-devicons', 'nvimdev/lspsaga.nvim', + 'linrongbin16/lsp-progress.nvim', }, after = 'rcarriga/nvim-dap-ui', config = function() -- Setup -- + require('lsp-progress').setup() local lspsaga_breadcrumbs = require('lspsaga.symbol.winbar').get_bar require('lualine').setup({ @@ -39,8 +41,11 @@ return { }, sections = { lualine_a = { 'mode' }, - lualine_b = { 'diagnostics' }, - lualine_c = { lspsaga_breadcrumbs }, + lualine_b = { + function() return require('lsp-progress').progress() end, + }, + lualine_c = { 'diagnostics' }, + lualine_d = { lspsaga_breadcrumbs }, lualine_x = { 'location' }, lualine_y = { 'diff', 'branch' }, lualine_z = { 'filetype' }, diff --git a/lua/editor/theme.lua b/lua/editor/theme.lua index 8fb14a0..9495097 100644 --- a/lua/editor/theme.lua +++ b/lua/editor/theme.lua @@ -1,4 +1,4 @@ -local K = require('core.keymap') +--local K = require('core.keymap') return { { @@ -9,7 +9,7 @@ return { -- Set Theme -- vim.cmd('colorscheme catppuccin') end, - }, + },--[[ --TODO: Disabled, because it Conflicts with the Session Management { 'sunjon/shade.nvim', opts = { @@ -20,5 +20,5 @@ return { brightness_down = K.FOCUS_SHADE.DOWN.shortcut, }, }, - }, + },]]-- } diff --git a/lua/toolchain/angular.lua b/lua/toolchain/angular.lua new file mode 100644 index 0000000..abb6baf --- /dev/null +++ b/lua/toolchain/angular.lua @@ -0,0 +1,52 @@ +local T = require('toolchain') +local M = {} + +function M.setup() + T.add_highlighter_autoinstalls('angular') + + T.add_null_ls_module(function(null_ls) + return { + -- Diagnostics + null_ls.builtins.diagnostics.stylelint, + -- Formatter + null_ls.builtins.formatting.prettier.with({ + command = 'prettierd', + }), + } + end) + + T.add_lsp_autoinstalls('angularls') + + T.add_lsps(function(lspconfig, capabilities) + local config = { capabilities = capabilities } + lspconfig.html.setup(config) + lspconfig.emmet_ls.setup(config) + lspconfig.cssls.setup(config) + lspconfig.tailwindcss.setup(config) + lspconfig.ts_ls.setup(config) + lspconfig.eslint.setup(config) + end) + + T.add_plugins({ + 'joeveiga/ng.nvim', + config = function() + local opts = { noremap = true, silent = true } + local ng = require('ng') + vim.keymap.set( + 'n', + 'at', + ng.goto_template_for_component, + opts + ) + vim.keymap.set( + 'n', + 'ac', + ng.goto_component_with_template_file, + opts + ) + vim.keymap.set('n', 'aT', ng.get_template_tcb, opts) + end, + }) +end + +return M diff --git a/lua/toolchain/init.lua b/lua/toolchain/init.lua index 7d08782..65197b5 100644 --- a/lua/toolchain/init.lua +++ b/lua/toolchain/init.lua @@ -104,6 +104,7 @@ function TOOLCHAINS.init() require('toolchain.scripts').setup() require('toolchain.text').setup() require('toolchain.web').setup() + require('toolchain.angular').setup() end return TOOLCHAINS diff --git a/selene.toml b/selene.toml new file mode 100644 index 0000000..5867a2a --- /dev/null +++ b/selene.toml @@ -0,0 +1,4 @@ +std="vim" + +[lints] +mixed_table="allow" diff --git a/vim.toml b/vim.toml new file mode 100644 index 0000000..9f8bd15 --- /dev/null +++ b/vim.toml @@ -0,0 +1,5 @@ +[selene] +base = "lua51" + +[vim] +any = true