diff --git a/dot_config/nushell/config.nu b/dot_config/nushell/config.nu index a6398ac..391af3d 100644 --- a/dot_config/nushell/config.nu +++ b/dot_config/nushell/config.nu @@ -1,154 +1,10 @@ -# Nushell Config File -# -# version = "0.100.0" - -# For more information on defining custom themes, see -# https://www.nushell.sh/book/coloring_and_theming.html -# And here is the theme collection -# https://github.com/nushell/nu_scripts/tree/main/themes -let dark_theme = { - # color for nushell primitives - separator: white - # no fg, no bg, attr none effectively turns this off - leading_trailing_space_bg: { attr: n } - header: green_bold - empty: blue - # Closures can be used to choose colors for specific values. - # The value (in this case, a bool) is piped into the closure. - # eg) {|| if $in { 'light_cyan' } else { 'light_gray' } } - bool: light_cyan - int: white - filesize: cyan - duration: white - date: purple - range: white - float: white - string: white - nothing: white - binary: white - cell-path: white - row_index: green_bold - record: white - list: white - block: white - hints: dark_gray - search_result: { bg: red fg: white } - shape_and: purple_bold - shape_binary: purple_bold - shape_block: blue_bold - shape_bool: light_cyan - shape_closure: green_bold - shape_custom: green - shape_datetime: cyan_bold - shape_directory: cyan - shape_external: cyan - shape_externalarg: green_bold - shape_external_resolved: light_yellow_bold - shape_filepath: cyan - shape_flag: blue_bold - shape_float: purple_bold - # shapes are used to change the cli syntax highlighting - shape_garbage: { fg: white bg: red attr: b } - shape_glob_interpolation: cyan_bold - shape_globpattern: cyan_bold - shape_int: purple_bold - shape_internalcall: cyan_bold - shape_keyword: cyan_bold - shape_list: cyan_bold - shape_literal: blue - shape_match_pattern: green - shape_matching_brackets: { attr: u } - shape_nothing: light_cyan - shape_operator: yellow - shape_or: purple_bold - shape_pipe: purple_bold - shape_range: yellow_bold - shape_record: cyan_bold - shape_redirection: purple_bold - shape_signature: green_bold - shape_string: green - shape_string_interpolation: cyan_bold - shape_table: blue_bold - shape_variable: purple - shape_vardecl: purple - shape_raw_string: light_purple -} - -let light_theme = { - # color for nushell primitives - separator: dark_gray - # no fg, no bg, attr none effectively turns this off - leading_trailing_space_bg: { attr: n } - header: green_bold - empty: blue - # Closures can be used to choose colors for specific values. - # The value (in this case, a bool) is piped into the closure. - # eg) {|| if $in { 'dark_cyan' } else { 'dark_gray' } } - bool: dark_cyan - int: dark_gray - filesize: cyan_bold - duration: dark_gray - date: purple - range: dark_gray - float: dark_gray - string: dark_gray - nothing: dark_gray - binary: dark_gray - cell-path: dark_gray - row_index: green_bold - record: dark_gray - list: dark_gray - block: dark_gray - hints: dark_gray - search_result: { fg: white bg: red } - shape_and: purple_bold - shape_binary: purple_bold - shape_block: blue_bold - shape_bool: light_cyan - shape_closure: green_bold - shape_custom: green - shape_datetime: cyan_bold - shape_directory: cyan - shape_external: cyan - shape_externalarg: green_bold - shape_external_resolved: light_purple_bold - shape_filepath: cyan - shape_flag: blue_bold - shape_float: purple_bold - # shapes are used to change the cli syntax highlighting - shape_garbage: { fg: white bg: red attr: b } - shape_glob_interpolation: cyan_bold - shape_globpattern: cyan_bold - shape_int: purple_bold - shape_internalcall: cyan_bold - shape_keyword: cyan_bold - shape_list: cyan_bold - shape_literal: blue - shape_match_pattern: green - shape_matching_brackets: { attr: u } - shape_nothing: light_cyan - shape_operator: yellow - shape_or: purple_bold - shape_pipe: purple_bold - shape_range: yellow_bold - shape_record: cyan_bold - shape_redirection: purple_bold - shape_signature: green_bold - shape_string: green - shape_string_interpolation: cyan_bold - shape_table: blue_bold - shape_variable: purple - shape_vardecl: purple - shape_raw_string: light_purple -} +source ($nu.default-config-dir | path join 'themes.nu') # External completer example # let carapace_completer = {|spans| # carapace $spans.0 nushell ...$spans | from json # } -# The default config record. This is where much of your global configuration -# is setup. $env.config = { # true or false to enable or disable the welcome banner at startup show_banner: false @@ -176,6 +32,13 @@ $env.config = { show_empty: true # a left right padding of each column in a table padding: { left: 1, right: 1 } + # show header text on separator/border line + header_on_separator: false + # render footer in parent table if child is big enough + # (extended table option) + footer_inheritance: false + # limit data rows from top and bottom after reaching a set point + # abbreviated_row_count: 10 trim: { # wrapping or truncating methodology: wrapping @@ -184,13 +47,6 @@ $env.config = { # A suffix used by the 'truncating' methodology truncating_suffix: "…" } - # show header text on separator/border line - header_on_separator: false - # render footer in parent table if child is big enough - # (extended table option) - footer_inheritance: false - # limit data rows from top and bottom after reaching a set point - # abbreviated_row_count: 10 } # "fancy" or "plain" for screen reader-friendly error messages @@ -259,6 +115,9 @@ $env.config = { # "smart" (alphabetical for prefix matching, fuzzy score for # fuzzy matching) or "alphabetical" sort: "smart" + # set this to true to enable file/path/directory completions + # using LS_COLORS + use_ls_colors: true external: { # set to false to prevent nushell looking into $env.PATH to find # more suggestions, `false` recommended for WSL users as this look @@ -270,9 +129,6 @@ $env.config = { # check 'carapace_completer' above as an example completer: null } - # set this to true to enable file/path/directory completions - # using LS_COLORS - use_ls_colors: true } filesize: { @@ -299,7 +155,7 @@ $env.config = { #color_config: $dark_theme # if you want a more interesting theme, you can replace the empty record # with `$dark_theme`, `$light_theme` or another custom record - color_config: $light_theme + color_config: $dark_theme # always, never, number_of_rows, auto footer_mode: 25 # the precision for displaying floats in tables diff --git a/dot_config/nvim/lua/plugins/autocompletion.lua b/dot_config/nvim/lua/plugins/autocompletion.lua index 16e345d..2174711 100644 --- a/dot_config/nvim/lua/plugins/autocompletion.lua +++ b/dot_config/nvim/lua/plugins/autocompletion.lua @@ -1,4 +1,12 @@ -local function config() +local M = { 'hrsh7th/nvim-cmp' } + +M.name = 'cmp' +M.dependencies = { + 'saadparwaiz1/cmp_luasnip', + 'hrsh7th/cmp-nvim-lsp', +} + +function M.config() local cmp = require 'cmp' local luasnip = require 'luasnip' @@ -51,12 +59,4 @@ local function config() } end -return { - 'hrsh7th/nvim-cmp', - name = 'cmp', - config = config, - dependencies = { - 'saadparwaiz1/cmp_luasnip', - 'hrsh7th/cmp-nvim-lsp', - }, -} +return M diff --git a/dot_config/nvim/lua/plugins/base.lua b/dot_config/nvim/lua/plugins/base.lua index f8f7cd5..0e8051f 100644 --- a/dot_config/nvim/lua/plugins/base.lua +++ b/dot_config/nvim/lua/plugins/base.lua @@ -1,8 +1,18 @@ -return { - 'tpope/vim-surround', - tag = 'v2.2', - dependencies = { - { 'tpope/vim-sleuth', tag = 'v2.0' }, - { 'numToStr/Comment.nvim', opts = {}, lazy = false }, - }, +-- https://github.com/tpope/vim-surround +-- surround.vim: Delete/change/add parentheses/quotes/XML-tags/much more with ease +local M = { 'tpope/vim-surround' } + +M.tag = 'v2.2' +M.dependencies = { + -- https://github.com/tpope/vim-sleuth + -- sleuth.vim: Heuristically set buffer options + { 'tpope/vim-sleuth', tag = 'v2.0' }, + + -- https://github.com/numToStr/Comment.nvim + -- 🧠 💪 // Smart and powerful comment plugin for neovim. + -- Supports treesitter, dot repeat, left-right/up-down motions, hooks, and more + { 'numToStr/Comment.nvim', opts = {}, lazy = false }, } + + +return M diff --git a/dot_config/nvim/lua/plugins/go.lua b/dot_config/nvim/lua/plugins/go.lua index e01f4d4..da23491 100644 --- a/dot_config/nvim/lua/plugins/go.lua +++ b/dot_config/nvim/lua/plugins/go.lua @@ -1,16 +1,21 @@ -local function config() - require("go").setup() -end +-- https://github.com/ray-x/go.nvim +-- A modern go neovim plugin based on treesitter, nvim-lsp and dap debugger. +local M = { 'ray-x/go.nvim' } + +M.name = 'go' +M.event = { 'CmdlineEnter' } +M.ft = { 'go', 'gomod' } +M.dependencies = { + -- https://github.com/ray-x/guihua.lua + -- Guihua: A Lua Gui and util library for nvim plugins + 'ray-x/guihua.lua', -return { - 'ray-x/go.nvim', - name = 'go', - config = config, - event = { 'CmdlineEnter' }, - ft = { 'go', 'gomod' }, - dependencies = { - 'ray-x/guihua.lua', - 'lspconfig', - 'treesitter', - }, + 'lspconfig', + 'treesitter', } + +function M.config() + require("go").setup() +end + +return M diff --git a/dot_config/nvim/lua/plugins/lsp.lua.tmpl b/dot_config/nvim/lua/plugins/lsp.lua.tmpl index 5bed01a..4e650b0 100644 --- a/dot_config/nvim/lua/plugins/lsp.lua.tmpl +++ b/dot_config/nvim/lua/plugins/lsp.lua.tmpl @@ -1,5 +1,17 @@ # chezmoi:template:left-delimiter=--{{ --{{- /* vim: set filetype=lua: */ -}} +local M = { 'neovim/nvim-lspconfig' } + +M.name = 'lspconfig' +M.tag = 'v1.0.0' + +M.dependencies = { + { 'j-hui/fidget.nvim', tag = 'legacy', opts = {} }, + { 'folke/trouble.nvim', tag = 'v3.6.0' }, + { 'folke/lazydev.nvim', tag = 'v1.9.0', ft = "lua", opts = {} }, +} + + local function format_buffer(_) vim.lsp.buf.format() end @@ -11,7 +23,7 @@ local function on_attach(_, buffer) }) end -local function config() +function M.config() local lspconfig = require('lspconfig') local capabilities = require('cmp_nvim_lsp').default_capabilities( @@ -25,6 +37,14 @@ local function config() settings = {}, } --{{- end }} + -- + --{{ if lookPath "buf" -}} + lspconfig.buf_ls.setup { + capabilities = capabilities, + on_attach = on_attach, + settings = {}, + } + --{{- end }} --{{ if lookPath "go" -}} lspconfig.gopls.setup { @@ -91,14 +111,4 @@ local function config() --{{- end }} end -return { - 'neovim/nvim-lspconfig', - name = 'lspconfig', - tag = 'v1.0.0', - config = config, - dependencies = { - { 'j-hui/fidget.nvim', tag = 'legacy', opts = {} }, - { 'folke/trouble.nvim', tag = 'v3.6.0' }, - { 'folke/lazydev.nvim', tag = 'v1.9.0', ft = "lua", opts = {} }, - }, -} +return M diff --git a/dot_config/nvim/lua/plugins/snippets.lua b/dot_config/nvim/lua/plugins/snippets.lua index 12867f0..bea33f4 100644 --- a/dot_config/nvim/lua/plugins/snippets.lua +++ b/dot_config/nvim/lua/plugins/snippets.lua @@ -1,13 +1,15 @@ -local function config() +-- https://github.com/L3MON4D3/LuaSnip +-- Snippet Engine for Neovim written in Lua. +local M = { 'L3MON4D3/LuaSnip' } + +M.tag = 'v2.3.0' +M.dependencies = {} + +function M.config() local luasnip = require 'luasnip' luasnip.setup() luasnip.config.setup({}) require("luasnip.loaders.from_snipmate").lazy_load() end -return { - 'L3MON4D3/LuaSnip', - config = config, - tag = 'v2.3.0', - dependencies = {}, -} +return M diff --git a/dot_config/nvim/lua/plugins/telescope.lua b/dot_config/nvim/lua/plugins/telescope.lua index 293ea54..b05c0e2 100644 --- a/dot_config/nvim/lua/plugins/telescope.lua +++ b/dot_config/nvim/lua/plugins/telescope.lua @@ -1,30 +1,21 @@ --- 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 +local lib = require('core.lib') +local M = { 'nvim-telescope/telescope.nvim' } - -- 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 +M.branch = '0.1.x' +M.event = 'VimEnter' +M.dependencies = { + 'nvim-lua/plenary.nvim', + { + 'nvim-telescope/telescope-fzf-native.nvim', + build = 'make', + }, + 'nvim-telescope/telescope-ui-select.nvim', + 'nvim-tree/nvim-web-devicons', +} -- Custom live_grep function to search in git root local function live_grep_git_root() - local git_root = find_git_root() + local git_root = lib.find_git_root() if git_root then require('telescope.builtin').live_grep({ search_dirs = { git_root }, @@ -34,7 +25,7 @@ end vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {}) -local function config() +function M.config() -- See `:help telescope` and `:help telescope.setup()` local telescope = require('telescope') local builtin = require('telescope.builtin') @@ -63,7 +54,7 @@ local function config() pcall(telescope.load_extension, 'fzf') pcall(telescope.load_extension, 'ui-select') - local function fuzzy_find () + local function fuzzy_find() -- You can pass additional configuration to telescope to change theme, -- layout, etc. builtin.current_buffer_fuzzy_find(themes.get_dropdown({ @@ -88,23 +79,4 @@ local function config() vim.keymap.set('n', 'gf', builtin.git_files, { desc = 'Search [G]it [F]iles' }) end -local function is_make_installed() - return vim.fn.executable('make') == 1 -end - -return { - 'nvim-telescope/telescope.nvim', - branch = '0.1.x', - config = config, - event = 'VimEnter', - dependencies = { - 'nvim-lua/plenary.nvim', - { - 'nvim-telescope/telescope-fzf-native.nvim', - cond = is_make_installed, - build = 'make', - }, - 'nvim-telescope/telescope-ui-select.nvim', - 'nvim-tree/nvim-web-devicons', - }, -} +return M diff --git a/dot_config/nvim/lua/plugins/theme.lua b/dot_config/nvim/lua/plugins/theme.lua index 4f16336..e5be584 100644 --- a/dot_config/nvim/lua/plugins/theme.lua +++ b/dot_config/nvim/lua/plugins/theme.lua @@ -1,25 +1,27 @@ -local function config() - vim.cmd.colorscheme 'gruvbox' -end +-- https://github.com/morhetz/gruvbox +local M = { 'morhetz/gruvbox' } -return { - 'morhetz/gruvbox', - priority = 1000, - config = config, - dependencies = { - 'nvim-lualine/lualine.nvim', - opts = { - options = { - theme = 'gruvbox', - }, - sections = { - lualine_a = { 'mode' }, - lualine_b = { 'diagnostics' }, - lualine_c = { { 'filename', path = 3 } }, - lualine_x = { 'encoding', 'fileformat', 'filetype' }, - lualine_y = { 'progress' }, - lualine_z = { 'location' } - }, +M.priority = 1000 +M.dependencies = { + -- https://github.com/nvim-lualine/lualine.nvim + 'nvim-lualine/lualine.nvim', + opts = { + options = { + theme = 'gruvbox', + }, + sections = { + lualine_a = { 'mode' }, + lualine_b = { 'diagnostics' }, + lualine_c = { { 'filename', path = 3 } }, + lualine_x = { 'encoding', 'fileformat', 'filetype' }, + lualine_y = { 'progress' }, + lualine_z = { 'location' } }, }, } + +function M.config() + vim.cmd.colorscheme 'gruvbox' +end + +return M diff --git a/dot_config/nvim/lua/plugins/tree.lua b/dot_config/nvim/lua/plugins/tree.lua index 331572a..7d98abf 100644 --- a/dot_config/nvim/lua/plugins/tree.lua +++ b/dot_config/nvim/lua/plugins/tree.lua @@ -2,7 +2,30 @@ vim.g.loaded_netrw = 1 vim.g.loaded_netrwPlugin = 1 vim.opt.termguicolors = true -local function handle_closed(window) +local M = { 'nvim-tree/nvim-tree.lua' } + +M.tag = 'nvim-tree-v1.9.0' + +M.keys = { + { 'nt', ':NvimTreeToggle', desc = 'toggle nvim tree' } +} + +M.dependencies = { + -- https://github.com/nvim-tree/nvim-web-devicons + 'nvim-tree/nvim-web-devicons', opts = {} +} + +function M.config() + require('nvim-tree').setup() + vim.api.nvim_create_autocmd('WinClosed', { + nested = true, + callback = function() + M.handle_closed(tonumber(vim.fn.expand(''))) + end, + }) +end + +function M.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] @@ -37,24 +60,4 @@ local function handle_closed(window) end 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 = {} - }, -} +return M diff --git a/dot_config/nvim/lua/plugins/treesitter.lua b/dot_config/nvim/lua/plugins/treesitter.lua index c69373b..57cc682 100644 --- a/dot_config/nvim/lua/plugins/treesitter.lua +++ b/dot_config/nvim/lua/plugins/treesitter.lua @@ -1,4 +1,21 @@ -local treesitter_config_setup = { +local M = {'nvim-treesitter/nvim-treesitter' } + +M.name = 'treesitter' +M.build = ':TSUpdate' +M.dependencies = { + 'nvim-treesitter/nvim-treesitter-textobjects' +} + +function M.config () + vim.defer_fn(M.treesitter_configs, 0) +end + +function M.treesitter_configs() + require 'nvim-treesitter.configs' + .setup(M.treesitter_config_setup) +end + +M.treesitter_config_setup = { -- Add languages to be installed here that you want installed for treesitter ensure_installed = { 'bash', 'c', 'cpp', 'go', 'lua', 'python', 'rust', @@ -74,22 +91,4 @@ local treesitter_config_setup = { }, } -local function treesitter_configs() - require 'nvim-treesitter.configs' - .setup(treesitter_config_setup) -end - -local function config() - vim.defer_fn(treesitter_configs, 0) -end - -return { - -- Highlight, edit, and navigate code - 'nvim-treesitter/nvim-treesitter', - name = 'treesitter', - config = config, - build = ':TSUpdate', - dependencies = { - 'nvim-treesitter/nvim-treesitter-textobjects', - }, -} +return M