From ec6733a0ea1197e7c86fc56df04ae999b57b4f5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noah=20H=C3=A5kansson?= Date: Mon, 29 Jan 2024 10:08:59 +0100 Subject: [PATCH] first version, bunch of plugins, keymaps and configuration --- .stylua.toml | 1 - init.lua | 257 +++++++++++++++--------- lazy-lock.json | 50 +++++ lua/custom/keymaps.lua | 39 ++++ lua/custom/options.lua | 5 + lua/custom/plugins/autopairs.lua | 12 ++ lua/custom/plugins/bqf.lua | 38 ++++ lua/custom/plugins/breadcrumbs.lua | 12 ++ lua/custom/plugins/colorizer.lua | 37 ++++ lua/custom/plugins/copilot.lua | 29 +++ lua/custom/plugins/devicons.lua | 10 + lua/custom/plugins/dial.lua | 76 +++++++ lua/custom/plugins/dressing.lua | 97 +++++++++ lua/custom/plugins/eyeliner.lua | 13 ++ lua/custom/plugins/harpoon.lua | 21 ++ lua/custom/plugins/illuminate.lua | 100 +++++++++ lua/custom/plugins/navic.lua | 20 ++ lua/custom/plugins/none-ls.lua | 34 ++++ lua/custom/plugins/nvimtree.lua | 113 +++++++++++ lua/custom/plugins/schemastore.lua | 8 + lua/custom/plugins/substitute.lua | 16 ++ lua/custom/plugins/surround.lua | 14 ++ lua/custom/plugins/typescript-tools.lua | 37 ++++ lua/utils/icons.lua | 158 +++++++++++++++ lua/utils/lualine/colors.lua | 16 ++ lua/utils/lualine/components.lua | 163 +++++++++++++++ lua/utils/lualine/conditions.lua | 17 ++ lua/utils/none-ls/formatters.lua | 31 +++ lua/utils/none-ls/linters.lua | 41 ++++ lua/utils/none-ls/services.lua | 56 ++++++ 30 files changed, 1425 insertions(+), 96 deletions(-) create mode 100644 lazy-lock.json create mode 100644 lua/custom/keymaps.lua create mode 100644 lua/custom/options.lua create mode 100644 lua/custom/plugins/autopairs.lua create mode 100644 lua/custom/plugins/bqf.lua create mode 100644 lua/custom/plugins/breadcrumbs.lua create mode 100644 lua/custom/plugins/colorizer.lua create mode 100644 lua/custom/plugins/copilot.lua create mode 100644 lua/custom/plugins/devicons.lua create mode 100644 lua/custom/plugins/dial.lua create mode 100644 lua/custom/plugins/dressing.lua create mode 100644 lua/custom/plugins/eyeliner.lua create mode 100644 lua/custom/plugins/harpoon.lua create mode 100644 lua/custom/plugins/illuminate.lua create mode 100644 lua/custom/plugins/navic.lua create mode 100644 lua/custom/plugins/none-ls.lua create mode 100644 lua/custom/plugins/nvimtree.lua create mode 100644 lua/custom/plugins/schemastore.lua create mode 100644 lua/custom/plugins/substitute.lua create mode 100644 lua/custom/plugins/surround.lua create mode 100644 lua/custom/plugins/typescript-tools.lua create mode 100644 lua/utils/icons.lua create mode 100644 lua/utils/lualine/colors.lua create mode 100644 lua/utils/lualine/components.lua create mode 100644 lua/utils/lualine/conditions.lua create mode 100644 lua/utils/none-ls/formatters.lua create mode 100644 lua/utils/none-ls/linters.lua create mode 100644 lua/utils/none-ls/services.lua diff --git a/.stylua.toml b/.stylua.toml index 139e9397..4a01b0e5 100644 --- a/.stylua.toml +++ b/.stylua.toml @@ -3,4 +3,3 @@ line_endings = "Unix" indent_type = "Spaces" indent_width = 2 quote_style = "AutoPreferSingle" -call_parentheses = "None" diff --git a/init.lua b/init.lua index 1ff16af5..116ca90c 100644 --- a/init.lua +++ b/init.lua @@ -47,19 +47,21 @@ vim.g.maplocalleader = ' ' -- [[ Install `lazy.nvim` plugin manager ]] -- https://github.com/folke/lazy.nvim -- `:help lazy.nvim.txt` for more info -local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' +local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim' if not vim.loop.fs_stat(lazypath) then - vim.fn.system { + vim.fn.system({ 'git', 'clone', '--filter=blob:none', 'https://github.com/folke/lazy.nvim.git', '--branch=stable', -- latest stable release lazypath, - } + }) end vim.opt.rtp:prepend(lazypath) +local icons = require('utils.icons') +local lualine_components = require('utils.lualine.components') -- [[ Configure plugins ]] -- NOTE: Here is where you install your plugins. -- You can configure plugins using the `config` key. @@ -88,7 +90,7 @@ require('lazy').setup({ -- Useful status updates for LSP -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` - { 'j-hui/fidget.nvim', opts = {} }, + { 'j-hui/fidget.nvim', opts = {} }, -- Additional lua configuration, makes nvim stuff amazing! 'folke/neodev.nvim', @@ -113,18 +115,18 @@ require('lazy').setup({ }, -- Useful plugin to show you pending keybinds. - { 'folke/which-key.nvim', opts = {} }, + { 'folke/which-key.nvim', opts = {} }, { -- Adds git related signs to the gutter, as well as utilities for managing changes 'lewis6991/gitsigns.nvim', opts = { -- See `:help gitsigns.txt` signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, + add = { text = icons.git.LineAdded }, + change = { text = icons.git.LineModified }, + delete = { text = icons.git.FileDeleted }, + topdelete = { text = icons.git.FileDeleted }, + changedelete = { text = icons.git.LineModified }, }, on_attach = function(bufnr) local gs = package.loaded.gitsigns @@ -158,30 +160,36 @@ require('lazy').setup({ -- Actions -- visual mode - map('v', 'hs', function() - gs.stage_hunk { vim.fn.line '.', vim.fn.line 'v' } - end, { desc = 'stage git hunk' }) - map('v', 'hr', function() - gs.reset_hunk { vim.fn.line '.', vim.fn.line 'v' } - end, { desc = 'reset git hunk' }) + -- map('v', 'gs', function() + -- gs.stage_hunk({ vim.fn.line('.'), vim.fn.line('v') }) + -- end, { desc = 'stage git hunk' }) + -- map('v', 'gr', function() + -- gs.reset_hunk({ vim.fn.line('.'), vim.fn.line('v') }) + -- end, { desc = 'reset git hunk' }) -- normal mode - map('n', 'hs', gs.stage_hunk, { desc = 'git stage hunk' }) - map('n', 'hr', gs.reset_hunk, { desc = 'git reset hunk' }) - map('n', 'hS', gs.stage_buffer, { desc = 'git Stage buffer' }) - map('n', 'hu', gs.undo_stage_hunk, { desc = 'undo stage hunk' }) - map('n', 'hR', gs.reset_buffer, { desc = 'git Reset buffer' }) - map('n', 'hp', gs.preview_hunk, { desc = 'preview git hunk' }) - map('n', 'hb', function() - gs.blame_line { full = false } + map('n', 'gj', gs.next_hunk, { desc = 'git stage hunk' }) + map('n', 'gk', gs.prev_hunk, { desc = 'git stage hunk' }) + -- map('n', 'gs', gs.stage_hunk, { desc = 'git stage hunk' }) + -- map('n', 'gr', gs.reset_hunk, { desc = 'git reset hunk' }) + -- map('n', 'gS', gs.stage_buffer, { desc = 'git Stage buffer' }) + -- map('n', 'gu', gs.undo_stage_hunk, { desc = 'undo stage hunk' }) + -- map('n', 'gR', gs.reset_buffer, { desc = 'git Reset buffer' }) + map('n', 'gp', gs.preview_hunk, { desc = 'preview git hunk' }) + map('n', 'gb', function() + gs.blame_line({ full = false }) end, { desc = 'git blame line' }) - map('n', 'hd', gs.diffthis, { desc = 'git diff against index' }) - map('n', 'hD', function() - gs.diffthis '~' + map('n', 'gd', gs.diffthis, { desc = 'git diff against index' }) + map('n', 'gD', function() + gs.diffthis('~') end, { desc = 'git diff against last commit' }) -- Toggles - map('n', 'tb', gs.toggle_current_line_blame, { desc = 'toggle git blame line' }) - map('n', 'td', gs.toggle_deleted, { desc = 'toggle git show deleted' }) + + require('which-key').register({ + ['gt'] = { name = '[G]it [T]oggles', _ = 'which_key_ignore' }, + }) + map('n', 'gtb', gs.toggle_current_line_blame, { desc = 'toggle git blame line' }) + map('n', 'gtd', gs.toggle_deleted, { desc = 'toggle git show deleted' }) -- Text object map({ 'o', 'x' }, 'ih', ':Gitsigns select_hunk', { desc = 'select git hunk' }) @@ -194,7 +202,7 @@ require('lazy').setup({ 'navarasu/onedark.nvim', priority = 1000, config = function() - vim.cmd.colorscheme 'onedark' + vim.cmd.colorscheme('onedark') end, }, @@ -202,13 +210,40 @@ require('lazy').setup({ -- Set lualine as statusline 'nvim-lualine/lualine.nvim', -- See `:help lualine.txt` + dependencies = { + 'kyazdani42/nvim-web-devicons', + }, opts = { options = { - icons_enabled = false, + icons_enabled = true, theme = 'onedark', component_separators = '|', section_separators = '', }, + sections = { + lualine_a = { + 'mode', + }, + lualine_b = { + lualine_components.branch, + lualine_components.filename, + }, + lualine_c = { + lualine_components.diff, + }, + lualine_x = { + lualine_components.diagnostics, + lualine_components.lsp, + lualine_components.copilot, + lualine_components.spaces, + lualine_components.filetype, + }, + lualine_y = { lualine_components.location }, + lualine_z = { + lualine_components.progress, + }, + }, + extensions = { 'fugitive', 'nvim-tree' }, }, }, @@ -239,7 +274,7 @@ require('lazy').setup({ -- refer to the README for telescope-fzf-native for more instructions. build = 'make', cond = function() - return vim.fn.executable 'make' == 1 + return vim.fn.executable('make') == 1 end, }, }, @@ -257,8 +292,8 @@ require('lazy').setup({ -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart -- These are some example plugins that I've included in the kickstart repository. -- Uncomment any of the lines below to enable them. - -- require 'kickstart.plugins.autoformat', - -- require 'kickstart.plugins.debug', + require('kickstart.plugins.autoformat'), + require('kickstart.plugins.debug'), -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` -- You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping @@ -266,7 +301,7 @@ require('lazy').setup({ -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. -- -- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, }, {}) -- [[ Setting options ]] @@ -274,7 +309,7 @@ require('lazy').setup({ -- NOTE: You can change these options as you wish! -- Set highlight on search -vim.o.hlsearch = false +vim.o.hlsearch = true -- Make line numbers default vim.wo.number = true @@ -309,6 +344,8 @@ vim.o.completeopt = 'menuone,noselect' -- NOTE: You should make sure your terminal supports this vim.o.termguicolors = true +-- require additional custom options +require('custom.options') -- [[ Basic Keymaps ]] @@ -325,6 +362,8 @@ vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous dia vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) +-- require additional custom keymaps +require('custom.keymaps') -- [[ Highlight on yank ]] -- See `:help vim.highlight.on_yank()` @@ -339,7 +378,7 @@ vim.api.nvim_create_autocmd('TextYankPost', { -- [[ Configure Telescope ]] -- See `:help telescope` and `:help telescope.setup()` -require('telescope').setup { +require('telescope').setup({ defaults = { mappings = { i = { @@ -348,7 +387,7 @@ require('telescope').setup { }, }, }, -} +}) -- Enable telescope fzf native, if installed pcall(require('telescope').load_extension, 'fzf') @@ -371,7 +410,7 @@ local function find_git_root() -- 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' + print('Not a git repository. Searching on current working directory') return cwd end return git_root @@ -381,34 +420,46 @@ end local function live_grep_git_root() local git_root = find_git_root() if git_root then - require('telescope.builtin').live_grep { + require('telescope.builtin').live_grep({ search_dirs = { git_root }, - } + }) end end vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {}) -- See `:help telescope.builtin` -vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) +-- vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) -vim.keymap.set('n', '/', function() - -- You can pass additional configuration to telescope to change theme, layout, etc. - require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { - winblend = 10, - previewer = false, - }) -end, { desc = '[/] Fuzzily search in current buffer' }) +-- vim.keymap.set('n', '/', function() +-- -- You can pass additional configuration to telescope to change theme, layout, etc. +-- require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { +-- winblend = 10, +-- previewer = false, +-- }) +-- end, { desc = '[/] Fuzzily search in current buffer' }) + +-- Smartly opens either git_files or find_files, depending on whether the working directory is +-- contained in a Git repo. +local function find_project_files(opts) + opts = opts or {} + opts.show_untracked = true + local ok = pcall(require('telescope.builtin').git_files, opts) + + if not ok then + require('telescope.builtin').find_files(opts) + end +end local function telescope_live_grep_open_files() - require('telescope.builtin').live_grep { + require('telescope.builtin').live_grep({ grep_open_files = true, prompt_title = 'Live Grep in Open Files', - } + }) end +vim.keymap.set('n', 'f', find_project_files, { desc = '[F]ind Files' }) vim.keymap.set('n', 's/', telescope_live_grep_open_files, { desc = '[S]earch [/] in Open Files' }) vim.keymap.set('n', 'ss', require('telescope.builtin').builtin, { desc = '[S]earch [S]elect Telescope' }) -vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) @@ -421,12 +472,12 @@ vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = -- See `:help nvim-treesitter` -- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}' vim.defer_fn(function() - require('nvim-treesitter.configs').setup { + require('nvim-treesitter.configs').setup({ -- Add languages to be installed here that you want installed for treesitter ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim', 'bash' }, -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) - auto_install = false, + auto_install = true, -- Install languages synchronously (only applied to `ensure_installed`) sync_install = false, -- List of parsers to ignore installing @@ -488,7 +539,7 @@ vim.defer_fn(function() }, }, }, - } + }) end, 0) -- [[ Configure LSP ]] @@ -508,27 +559,26 @@ local on_attach = function(_, bufnr) vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) end - nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') - nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') - nmap('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') - nmap('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') - nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') - nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + nmap('lt', require('telescope.builtin').lsp_type_definitions, '[T]ype Definition') + nmap('ls', require('telescope.builtin').lsp_document_symbols, 'Document [S]ymbols') + nmap('lS', require('telescope.builtin').lsp_dynamic_workspace_symbols, 'Workspace [S]ymbols') + nmap('la', vim.lsp.buf.code_action, '[L]sp Code [A]ction') + nmap('lr', vim.lsp.buf.rename, '[L]sp [R]ename') -- See `:help K` for why this keymap nmap('K', vim.lsp.buf.hover, 'Hover Documentation') - nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') + -- nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') -- Lesser used LSP functionality nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') - nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') - nmap('wl', function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, '[W]orkspace [L]ist Folders') + -- nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') + -- nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') + -- nmap('wl', function() + -- print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + -- end, '[W]orkspace [L]ist Folders') -- Create a command `:Format` local to the LSP buffer vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) @@ -537,21 +587,21 @@ local on_attach = function(_, bufnr) end -- document existing key chains -require('which-key').register { +require('which-key').register({ ['c'] = { name = '[C]ode', _ = 'which_key_ignore' }, ['d'] = { name = '[D]ocument', _ = 'which_key_ignore' }, ['g'] = { name = '[G]it', _ = 'which_key_ignore' }, - ['h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' }, + -- ['h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' }, ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, ['t'] = { name = '[T]oggle', _ = 'which_key_ignore' }, - ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, -} + -- ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, +}) -- register which-key VISUAL mode -- required for visual hs (hunk stage) to work require('which-key').register({ [''] = { name = 'VISUAL ' }, - ['h'] = { 'Git [H]unk' }, + -- ['h'] = { 'Git [H]unk' }, }, { mode = 'v' }) -- mason-lspconfig requires that these setup functions are called in this order @@ -568,13 +618,12 @@ require('mason-lspconfig').setup() -- If you want to override the default filetypes that your language server will attach to you can -- define the property 'filetypes' to the map in question. local servers = { - -- clangd = {}, - -- gopls = {}, - -- pyright = {}, - -- rust_analyzer = {}, + clangd = {}, + gopls = {}, + pyright = {}, + rust_analyzer = {}, -- tsserver = {}, - -- html = { filetypes = { 'html', 'twig', 'hbs'} }, - + html = { filetypes = { 'html', 'twig', 'hbs' } }, lua_ls = { Lua = { workspace = { checkThirdParty = false }, @@ -583,6 +632,24 @@ local servers = { -- diagnostics = { disable = { 'missing-fields' } }, }, }, + jsonls = { + json = { + schemas = require('schemastore').json.schemas(), + validate = { enable = true }, + }, + }, + yamlls = { + yaml = { + schemaStore = { + -- You must disable built-in schemaStore support if you want to use + -- this plugin and its advanced options like `ignore`. + enable = false, + -- Avoid TypeError: Cannot read properties of undefined (reading 'length') + url = '', + }, + schemas = require('schemastore').yaml.schemas(), + }, + }, } -- Setup neovim lua configuration @@ -593,31 +660,31 @@ local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) -- Ensure the servers above are installed -local mason_lspconfig = require 'mason-lspconfig' +local mason_lspconfig = require('mason-lspconfig') -mason_lspconfig.setup { +mason_lspconfig.setup({ ensure_installed = vim.tbl_keys(servers), -} +}) -mason_lspconfig.setup_handlers { +mason_lspconfig.setup_handlers({ function(server_name) - require('lspconfig')[server_name].setup { + require('lspconfig')[server_name].setup({ capabilities = capabilities, on_attach = on_attach, settings = servers[server_name], filetypes = (servers[server_name] or {}).filetypes, - } + }) end, -} +}) -- [[ Configure nvim-cmp ]] -- See `:help cmp` -local cmp = require 'cmp' -local luasnip = require 'luasnip' +local cmp = require('cmp') +local luasnip = require('luasnip') require('luasnip.loaders.from_vscode').lazy_load() -luasnip.config.setup {} +luasnip.config.setup({}) -cmp.setup { +cmp.setup({ snippet = { expand = function(args) luasnip.lsp_expand(args.body) @@ -626,16 +693,16 @@ cmp.setup { completion = { completeopt = 'menu,menuone,noinsert', }, - mapping = cmp.mapping.preset.insert { + mapping = cmp.mapping.preset.insert({ [''] = cmp.mapping.select_next_item(), [''] = cmp.mapping.select_prev_item(), [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete {}, - [''] = cmp.mapping.confirm { + [''] = cmp.mapping.complete({}), + [''] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true, - }, + }), [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() @@ -654,13 +721,13 @@ cmp.setup { fallback() end end, { 'i', 's' }), - }, + }), sources = { { name = 'nvim_lsp' }, { name = 'luasnip' }, { name = 'path' }, }, -} +}) -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 00000000..99c597b3 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,50 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, + "LuaSnip": { "branch": "master", "commit": "2dbef19461198630b3d7c39f414d09fb07d1fdd2" }, + "breadcrumbs.nvim": { "branch": "master", "commit": "9f764278784ce2f10dbe2f555ba14be2451d36a0" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "copilot.lua": { "branch": "master", "commit": "b03617a6dc4bc88b65ab5deac1631da9a9c2dcaf" }, + "dial.nvim": { "branch": "master", "commit": "27eb570085db2ef44bff4f620d3806039184651c" }, + "dressing.nvim": { "branch": "master", "commit": "0e88293ce3459f4bb310125f3366304af6dc7990" }, + "eyeliner.nvim": { "branch": "main", "commit": "c540d58bf52aa979d4cca639c60387ae0c0ccf88" }, + "fidget.nvim": { "branch": "main", "commit": "1d1042d418ee8cb70d68f1e38db639844331c093" }, + "friendly-snippets": { "branch": "main", "commit": "aced40b66b7bae9bc2c37fd7b11841d54727a7b0" }, + "gitsigns.nvim": { "branch": "main", "commit": "2c2463dbd82eddd7dbab881c3a62cfbfbe3c67ae" }, + "harpoon": { "branch": "master", "commit": "ccae1b9bec717ae284906b0bf83d720e59d12b91" }, + "indent-blankline.nvim": { "branch": "master", "commit": "12e92044d313c54c438bd786d11684c88f6f78cd" }, + "lazy.nvim": { "branch": "main", "commit": "aedcd79811d491b60d0a6577a9c1701063c2a609" }, + "lualine.nvim": { "branch": "master", "commit": "7d131a8d3ba5016229e8a1d08bf8782acea98852" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "b9084b1f42f790d6230dc66dbcb6bcc35b148552" }, + "mason-nvim-dap.nvim": { "branch": "main", "commit": "3614a39aae98ccd34124b072939d6283853b3dd2" }, + "mason.nvim": { "branch": "main", "commit": "dcd0ea30ccfc7d47e879878d1270d6847a519181" }, + "neodev.nvim": { "branch": "main", "commit": "64b2a51b02c6f2ae177c745e4d8bc801a339fe09" }, + "none-ls.nvim": { "branch": "main", "commit": "912f81829e9ab4ee3d54c3ea5a304c264f0003bc" }, + "nvim-autopairs": { "branch": "master", "commit": "096d0baecc34f6c5d8a6dd25851e9d5ad338209b" }, + "nvim-bqf": { "branch": "main", "commit": "bdc2a4e5bb670b3c0e33ada9c0eec636d93a0748" }, + "nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "85855b38011114929f4058efc97af1059ab3e41d" }, + "nvim-dap": { "branch": "master", "commit": "9adbfdca13afbe646d09a8d7a86d5d031fb9c5a5" }, + "nvim-dap-go": { "branch": "main", "commit": "a5cc8dcad43f0732585d4793deb02a25c4afb766" }, + "nvim-dap-ui": { "branch": "master", "commit": "d845ebd798ad1cf30aa4abd4c4eff795cdcfdd4f" }, + "nvim-lspconfig": { "branch": "master", "commit": "8917d2c830e04bf944a699b8c41f097621283828" }, + "nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" }, + "nvim-surround": { "branch": "main", "commit": "703ec63aa798e5e07d309b35e42def34bebe0174" }, + "nvim-tree.lua": { "branch": "master", "commit": "7bdb220d0fe604a77361e92cdbc7af1b8a412126" }, + "nvim-treesitter": { "branch": "master", "commit": "6f586875e35e2b02358efa467317634c766fd1d4" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "19a91a38b02c1c28c14e0ba468d20ae1423c39b2" }, + "nvim-web-devicons": { "branch": "master", "commit": "b427ac5f9dff494f839e81441fb3f04a58cbcfbc" }, + "onedark.nvim": { "branch": "master", "commit": "14e5de43cf1ff761c280d1ff5b9980897f5b46c7" }, + "plenary.nvim": { "branch": "master", "commit": "663246936325062427597964d81d30eaa42ab1e4" }, + "schemastore.nvim": { "branch": "main", "commit": "85009f1efcea501d40fb7f575319516d5f93feaf" }, + "substitute.nvim": { "branch": "main", "commit": "17ffaeb5a1dc2dbef39cf0865d8a4b6000836714" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, + "telescope.nvim": { "branch": "0.1.x", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, + "typescript-tools.nvim": { "branch": "master", "commit": "c43d9580c3ff5999a1eabca849f807ab33787ea7" }, + "vim-fugitive": { "branch": "master", "commit": "f116dcc8e21021e6fbfb6b0a9f8f7b9566d933f4" }, + "vim-illuminate": { "branch": "master", "commit": "97c1265ff0b67064b6cfdc15bafc50202a537ae2" }, + "vim-rhubarb": { "branch": "master", "commit": "ee69335de176d9325267b0fd2597a22901d927b1" }, + "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, + "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" } +} \ No newline at end of file diff --git a/lua/custom/keymaps.lua b/lua/custom/keymaps.lua new file mode 100644 index 00000000..b14b0f19 --- /dev/null +++ b/lua/custom/keymaps.lua @@ -0,0 +1,39 @@ +-- +-- Additional keymaps +-- + +local wk = require('which-key') + +-- basic navigation +wk.register({ + ['w'] = { name = '', _ = 'which_key_ignore' }, +}) +vim.keymap.set('n', 'wh', 'h', { noremap = true, silent = true, desc = 'move to left window' }) +vim.keymap.set('n', 'wj', 'j', { noremap = true, silent = true, desc = 'move to bottom window' }) +vim.keymap.set('n', 'wk', 'k', { noremap = true, silent = true, desc = 'move to top window' }) +vim.keymap.set('n', 'wl', 'l', { noremap = true, silent = true, desc = 'move to right window' }) +vim.keymap.set('n', 'ws', 's', { noremap = true, silent = true, desc = 'split window horizontally' }) +vim.keymap.set('n', 'wv', 'v', { noremap = true, silent = true, desc = 'split window vertically' }) +vim.keymap.set('n', 'wc', 'c', { noremap = true, silent = true, desc = 'close window' }) +vim.keymap.set('n', 'wq', 'q', { noremap = true, silent = true, desc = 'quit window' }) +vim.keymap.set('n', 'wo', 'o', { noremap = true, silent = true, desc = 'close all other windows' }) +vim.keymap.set('n', 'ww', 'w', { noremap = true, silent = true, desc = 'move to next window' }) +vim.keymap.set('n', 'w+', '+', { noremap = true, silent = true, desc = 'increase window height' }) +vim.keymap.set('n', 'w-', '-', { noremap = true, silent = true, desc = 'decrease window height' }) +vim.keymap.set('n', 'w>', '>', { noremap = true, silent = true, desc = 'increase window width' }) +vim.keymap.set('n', 'w<', '<', { noremap = true, silent = true, desc = 'decrease window width' }) +vim.keymap.set('n', 'w=', '=', { noremap = true, silent = true, desc = 'balance window sizes' }) + +-- Turn off highlight when pressing Esc +vim.keymap.set('n', '', 'noh ', { noremap = false, silent = true }) + +-- fugitive +vim.keymap.set('n', 'gg', 'G', { desc = 'fugitive' }) + +-- magical base64 encoding/decoding +vim.keymap.set('n', '', 'viWy:let @"=system("openssl base64 -A", @")gv""P', { noremap = true, silent = true }) +vim.keymap.set('n', '', 'viWy:let @"=system("openssl base64 -A -d", @")gv""P', { noremap = true, silent = true }) + +-- Center next/previous search +vim.keymap.set('n', 'n', 'nzzzv', { noremap = true, silent = true }) +vim.keymap.set('n', 'N', 'Nzzzv', { noremap = true, silent = true }) diff --git a/lua/custom/options.lua b/lua/custom/options.lua new file mode 100644 index 00000000..459d325d --- /dev/null +++ b/lua/custom/options.lua @@ -0,0 +1,5 @@ +-- +-- Additional options +-- + +vim.o.cursorline = true diff --git a/lua/custom/plugins/autopairs.lua b/lua/custom/plugins/autopairs.lua new file mode 100644 index 00000000..92c08467 --- /dev/null +++ b/lua/custom/plugins/autopairs.lua @@ -0,0 +1,12 @@ +return { + 'windwp/nvim-autopairs', + -- Optional dependency + dependencies = { 'hrsh7th/nvim-cmp' }, + config = function() + require('nvim-autopairs').setup({}) + -- If you want to automatically add `(` after selecting a function or method + local cmp_autopairs = require('nvim-autopairs.completion.cmp') + local cmp = require('cmp') + cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) + end, +} diff --git a/lua/custom/plugins/bqf.lua b/lua/custom/plugins/bqf.lua new file mode 100644 index 00000000..150b759b --- /dev/null +++ b/lua/custom/plugins/bqf.lua @@ -0,0 +1,38 @@ +local M = { + 'kevinhwang91/nvim-bqf', + event = 'VeryLazy', +} + +function M.config() + require('bqf').setup({ + auto_enable = true, + magic_window = true, + auto_resize_height = false, + preview = { + auto_preview = true, + show_title = true, + delay_syntax = 50, + wrap = false, + }, + func_map = { + tab = 't', + openc = 'o', + drop = 'O', + split = 's', + vsplit = 'v', + stoggleup = 'M', + stoggledown = 'm', + stogglevm = 'm', + filterr = 'f', + filter = 'F', + prevhist = '<', + nexthist = '>', + sclear = 'c', + ptoggleitem = 'p', + ptoggleauto = 'a', + ptogglemode = 'P', + }, + }) +end + +return M diff --git a/lua/custom/plugins/breadcrumbs.lua b/lua/custom/plugins/breadcrumbs.lua new file mode 100644 index 00000000..1d3be069 --- /dev/null +++ b/lua/custom/plugins/breadcrumbs.lua @@ -0,0 +1,12 @@ +local M = { + "LunarVim/breadcrumbs.nvim", + dependencies = { + { "SmiteshP/nvim-navic" }, + }, +} + +function M.config() + require("breadcrumbs").setup() +end + +return M diff --git a/lua/custom/plugins/colorizer.lua b/lua/custom/plugins/colorizer.lua new file mode 100644 index 00000000..9bed948e --- /dev/null +++ b/lua/custom/plugins/colorizer.lua @@ -0,0 +1,37 @@ +local M = { + 'NvChad/nvim-colorizer.lua', + lazy = true, + event = 'VeryLazy', +} + +function M.config() + require('colorizer').setup({ + filetypes = { '*' }, + user_default_options = { + RGB = true, -- #RGB hex codes #ABC + RRGGBB = true, -- #RRGGBB hex codes #777AAA + names = true, -- "Name" codes like Blue or blue + RRGGBBAA = false, -- #RRGGBBAA hex codes + AARRGGBB = false, -- 0xAARRGGBB hex codes + rgb_fn = true, -- CSS rgb() and rgba() functions + hsl_fn = true, -- CSS hsl() and hsla() functions + css = true, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB + css_fn = true, -- Enable all CSS *functions*: rgb_fn, hsl_fn + -- Available modes for `mode`: foreground, background, virtualtext + mode = 'background', -- Set the display mode. + -- Available methods are false / true / "normal" / "lsp" / "both" + -- True is same as normal + tailwind = true, -- Enable tailwind colors + -- parsers can contain values used in |user_default_options| + sass = { enable = false, parsers = { 'css' } }, -- Enable sass colors + virtualtext = '■', + -- update color values even if buffer is not focused + -- example use: cmp_menu, cmp_docs + always_update = false, + }, + -- all the sub-options of filetypes apply to buftypes + buftypes = {}, + }) +end + +return M diff --git a/lua/custom/plugins/copilot.lua b/lua/custom/plugins/copilot.lua new file mode 100644 index 00000000..ac04daa2 --- /dev/null +++ b/lua/custom/plugins/copilot.lua @@ -0,0 +1,29 @@ +-- +-- copilot setup config +-- + +local M = { + 'zbirenbaum/copilot.lua', + event = 'BufRead', +} + +-- Copilot setup +function M.config() + require('copilot').setup({ + suggestion = { + enabled = true, + auto_trigger = true, + debounce = 50, + keymap = { + accept = '', + accept_word = '', + accept_line = '', + next = '', + prev = '', + dismiss = '', + }, + }, + }) +end + +return M diff --git a/lua/custom/plugins/devicons.lua b/lua/custom/plugins/devicons.lua new file mode 100644 index 00000000..10228b5d --- /dev/null +++ b/lua/custom/plugins/devicons.lua @@ -0,0 +1,10 @@ +local M = { + 'nvim-tree/nvim-web-devicons', + event = 'VeryLazy', +} + +function M.config() + require('nvim-web-devicons') +end + +return M diff --git a/lua/custom/plugins/dial.lua b/lua/custom/plugins/dial.lua new file mode 100644 index 00000000..a00e4c6b --- /dev/null +++ b/lua/custom/plugins/dial.lua @@ -0,0 +1,76 @@ +-- +-- dial.nvim +-- A plugin for incrementing and decrementing numbers, dates and switching booleans in Neovim. +-- + +local M = { 'monaqa/dial.nvim', event = 'VeryLazy' } + +function M.config() + local status_ok, dial_config = pcall(require, 'dial.config') + if not status_ok then + return + end + + local augend = require('dial.augend') + dial_config.augends:register_group({ + default = { + augend.integer.alias.decimal, + augend.integer.alias.hex, + augend.date.alias['%Y/%m/%d'], + }, + typescript = { + augend.integer.alias.decimal, + augend.integer.alias.hex, + augend.constant.new({ elements = { 'let', 'const' } }), + }, + visual = { + augend.integer.alias.decimal, + augend.integer.alias.hex, + augend.date.alias['%Y/%m/%d'], + augend.constant.alias.alpha, + augend.constant.alias.Alpha, + }, + mygroup = { + augend.constant.new({ + elements = { 'and', 'or' }, + word = true, -- if false, "sand" is incremented into "sor", "doctor" into "doctand", etc. + cyclic = true, -- "or" is incremented into "and". + }), + augend.constant.new({ + elements = { 'True', 'False' }, + word = true, + cyclic = true, + }), + augend.constant.new({ + elements = { 'public', 'private' }, + word = true, + cyclic = true, + }), + augend.constant.new({ + elements = { 'sad', 'sad' }, + word = true, + cyclic = true, + }), + augend.constant.new({ + elements = { '&&', '||' }, + word = false, + cyclic = true, + }), + augend.date.alias['%m/%d/%Y'], -- date (02/01/2022, etc.) + augend.constant.alias.bool, -- boolean value (true <-> false) + augend.integer.alias.decimal, + augend.integer.alias.hex, + augend.semver.alias.semver, + }, + }) + + local map = require('dial.map') + + -- change augends in VISUAL mode + vim.api.nvim_set_keymap('n', '', map.inc_normal('mygroup'), { noremap = true }) + vim.api.nvim_set_keymap('n', '', map.dec_normal('mygroup'), { noremap = true }) + vim.api.nvim_set_keymap('v', '', map.inc_normal('visual'), { noremap = true }) + vim.api.nvim_set_keymap('v', '', map.dec_normal('visual'), { noremap = true }) +end + +return M diff --git a/lua/custom/plugins/dressing.lua b/lua/custom/plugins/dressing.lua new file mode 100644 index 00000000..4d04457e --- /dev/null +++ b/lua/custom/plugins/dressing.lua @@ -0,0 +1,97 @@ +local M = { + 'stevearc/dressing.nvim', + event = 'VeryLazy', +} + +function M.config() + require('dressing').setup({ + input = { + -- Set to false to disable the vim.ui.input implementation + enabled = true, + + -- Default prompt string + default_prompt = 'Input:', + + -- Can be 'left', 'right', or 'center' + title_pos = 'left', + + -- When true, will close the modal + insert_only = false, + + -- When true, input will start in insert mode. + start_in_insert = true, + + -- These are passed to nvim_open_win + border = 'rounded', + -- 'editor' and 'win' will default to being centered + relative = 'cursor', + + -- These can be integers or a float between 0 and 1 (e.g. 0.4 for 40%) + prefer_width = 40, + width = nil, + -- min_width and max_width can be a list of mixed types. + -- min_width = {20, 0.2} means "the greater of 20 columns or 20% of total" + max_width = { 140, 0.9 }, + min_width = { 40, 0.2 }, + + buf_options = {}, + win_options = { + -- Window transparency (0-100) + winblend = 0, + -- Disable line wrapping + wrap = false, + -- Indicator for when text exceeds window + list = true, + listchars = 'precedes:…,extends:…', + -- Increase this for more context when text scrolls off the window + sidescrolloff = 0, + }, + + -- Set to `false` to disable + mappings = { + n = { + [''] = 'Close', + [''] = 'Confirm', + }, + i = { + [''] = 'Close', + [''] = 'Confirm', + [''] = 'HistoryPrev', + [''] = 'HistoryNext', + }, + }, + + override = function(conf) + -- This is the config that will be passed to nvim_open_win. + -- Change values here to customize the layout + return conf + end, + + -- see :help dressing_get_config + get_config = nil, + }, + select = { + -- Set to false to disable the vim.ui.select implementation + enabled = true, + + -- Priority list of preferred vim.select implementations + backend = { 'telescope', 'fzf_lua', 'fzf', 'builtin', 'nui' }, + + -- Trim trailing `:` from prompt + trim_prompt = true, + + -- Options for telescope selector + -- These are passed into the telescope picker directly. Can be used like: + -- telescope = require('telescope.themes').get_ivy({...}) + telescope = nil, + + -- Used to override format_item. See :help dressing-format + format_item_override = {}, + + -- see :help dressing_get_config + get_config = nil, + }, + }) +end + +return M diff --git a/lua/custom/plugins/eyeliner.lua b/lua/custom/plugins/eyeliner.lua new file mode 100644 index 00000000..1705e7df --- /dev/null +++ b/lua/custom/plugins/eyeliner.lua @@ -0,0 +1,13 @@ +local M = { + 'jinh0/eyeliner.nvim', + event = 'VeryLazy', +} + +function M.config() + require('eyeliner').setup({ + highlight_on_key = true, + dim = true, + }) +end + +return M diff --git a/lua/custom/plugins/harpoon.lua b/lua/custom/plugins/harpoon.lua new file mode 100644 index 00000000..ff050c1a --- /dev/null +++ b/lua/custom/plugins/harpoon.lua @@ -0,0 +1,21 @@ +local M = { + 'ThePrimeagen/harpoon', + event = 'VeryLazy', + dependencies = { + { 'nvim-lua/plenary.nvim' }, + }, +} + +function M.config() + local keymap = vim.keymap.set + local opts = { noremap = true, silent = true } + + keymap('n', '', "lua require('harpoon.mark').add_file()", opts) + keymap('n', '', "lua require('harpoon.ui').toggle_quick_menu()", opts) + keymap('n', '', "lua require('harpoon.ui').nav_file(1)", opts) + keymap('n', '', "lua require('harpoon.ui').nav_file(2)", opts) + keymap('n', '', "lua require('harpoon.ui').nav_file(3)", opts) + keymap('n', '', "lua require('harpoon.ui').nav_file(4)", opts) +end + +return M diff --git a/lua/custom/plugins/illuminate.lua b/lua/custom/plugins/illuminate.lua new file mode 100644 index 00000000..575f49f9 --- /dev/null +++ b/lua/custom/plugins/illuminate.lua @@ -0,0 +1,100 @@ +local M = { + 'RRethy/vim-illuminate', + event = 'VeryLazy', +} + +function M.config() + require('illuminate').configure({ + -- providers: provider used to get references in the buffer, ordered by priority + providers = { + 'lsp', + 'treesitter', + 'regex', + }, + -- delay: delay in milliseconds + delay = 100, + -- filetype_overrides: filetype specific overrides. + -- The keys are strings to represent the filetype while the values are tables that + -- supports the same keys passed to .configure except for filetypes_denylist and filetypes_allowlist + filetype_overrides = {}, + -- filetypes_denylist: filetypes to not illuminate, this overrides filetypes_allowlist + filetypes_denylist = { + 'mason', + 'harpoon', + 'DressingInput', + 'NeogitCommitMessage', + 'qf', + 'dirvish', + 'oil', + 'minifiles', + 'fugitive', + 'alpha', + 'NvimTree', + 'lazy', + 'NeogitStatus', + 'Trouble', + 'netrw', + 'lir', + 'DiffviewFiles', + 'Outline', + 'Jaq', + 'spectre_panel', + 'toggleterm', + 'DressingSelect', + 'TelescopePrompt', + }, + -- filetypes_allowlist: filetypes to illuminate, this is overridden by filetypes_denylist + -- You must set filetypes_denylist = {} to override the defaults to allow filetypes_allowlist to take effect + filetypes_allowlist = {}, + -- modes_denylist: modes to not illuminate, this overrides modes_allowlist + -- See `:help mode()` for possible values + modes_denylist = {}, + -- modes_allowlist: modes to illuminate, this is overridden by modes_denylist + -- See `:help mode()` for possible values + modes_allowlist = {}, + -- providers_regex_syntax_denylist: syntax to not illuminate, this overrides providers_regex_syntax_allowlist + -- Only applies to the 'regex' provider + -- Use :echom synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name') + providers_regex_syntax_denylist = {}, + -- providers_regex_syntax_allowlist: syntax to illuminate, this is overridden by providers_regex_syntax_denylist + -- Only applies to the 'regex' provider + -- Use :echom synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name') + providers_regex_syntax_allowlist = {}, + -- under_cursor: whether or not to illuminate under the cursor + under_cursor = true, + -- large_file_cutoff: number of lines at which to use large_file_config + -- The `under_cursor` option is disabled when this cutoff is hit + large_file_cutoff = nil, + -- large_file_config: config to use for large files (based on large_file_cutoff). + -- Supports the same keys passed to .configure + -- If nil, vim-illuminate will be disabled for large files. + large_file_overrides = nil, + -- min_count_to_highlight: minimum number of matches required to perform highlighting + min_count_to_highlight = 1, + -- should_enable: a callback that overrides all other settings to + -- enable/disable illumination. This will be called a lot so don't do + -- anything expensive in it. + should_enable = function(bufnr) + return true + end, + -- case_insensitive_regex: sets regex case sensitivity + case_insensitive_regex = false, + }) +end + +-- -- change the highlight style +-- vim.api.nvim_set_hl(0, 'IlluminatedWordText', { link = 'Visual' }) +-- vim.api.nvim_set_hl(0, 'IlluminatedWordRead', { link = 'Visual' }) +-- vim.api.nvim_set_hl(0, 'IlluminatedWordWrite', { link = 'Visual' }) +-- +-- --- auto update the highlight style on colorscheme change +-- vim.api.nvim_create_autocmd({ 'ColorScheme' }, { +-- pattern = { '*' }, +-- callback = function(ev) +-- vim.api.nvim_set_hl(0, 'IlluminatedWordText', { link = 'Visual' }) +-- vim.api.nvim_set_hl(0, 'IlluminatedWordRead', { link = 'Visual' }) +-- vim.api.nvim_set_hl(0, 'IlluminatedWordWrite', { link = 'Visual' }) +-- end, +-- }) + +return M diff --git a/lua/custom/plugins/navic.lua b/lua/custom/plugins/navic.lua new file mode 100644 index 00000000..94633f84 --- /dev/null +++ b/lua/custom/plugins/navic.lua @@ -0,0 +1,20 @@ +local M = { + 'SmiteshP/nvim-navic', +} + +function M.config() + local icons = require('utils.icons') + require('nvim-navic').setup({ + icons = icons.kind, + highlight = true, + lsp = { + auto_attach = true, + }, + click = true, + separator = ' ' .. icons.ui.ChevronRight .. ' ', + depth_limit = 0, + depth_limit_indicator = '..', + }) +end + +return M diff --git a/lua/custom/plugins/none-ls.lua b/lua/custom/plugins/none-ls.lua new file mode 100644 index 00000000..78b6863d --- /dev/null +++ b/lua/custom/plugins/none-ls.lua @@ -0,0 +1,34 @@ +local M = { + 'nvimtools/none-ls.nvim', + dependencies = { + 'nvim-lua/plenary.nvim', + }, +} + +function M.config() + local null_ls = require('null-ls') + + local formatting = null_ls.builtins.formatting + local diagnostics = null_ls.builtins.diagnostics + local code_actions = null_ls.builtins.code_actions + local completions = null_ls.builtins.completion + + null_ls.setup({ + debug = false, + sources = { + formatting.stylua, + formatting.black, + formatting.prettier.with({ + extra_filetypes = { 'toml' }, + -- extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" }, + }), + formatting.eslint_d, + diagnostics.eslint_d, + null_ls.builtins.diagnostics.flake8, + -- diagnostics.flake8, + code_actions.eslint_d, + }, + }) +end + +return M diff --git a/lua/custom/plugins/nvimtree.lua b/lua/custom/plugins/nvimtree.lua new file mode 100644 index 00000000..8a831caf --- /dev/null +++ b/lua/custom/plugins/nvimtree.lua @@ -0,0 +1,113 @@ +local M = { + 'nvim-tree/nvim-tree.lua', + event = 'VeryLazy', +} + +local function my_on_attach(bufnr) + local api = require('nvim-tree.api') + + local function opts(desc) + return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } + end + + -- default mappings + api.config.mappings.default_on_attach(bufnr) + + -- custom mappings + vim.keymap.set('n', 'l', api.node.open.edit, opts('Open')) + vim.keymap.set('n', 'o', api.node.open.edit, opts('Open')) + vim.keymap.set('n', '', api.node.open.edit, opts('Open')) + vim.keymap.set('n', 'v', api.node.open.vertical, opts('Open: Vertical Split')) + vim.keymap.set('n', 'h', api.node.open.horizontal, opts('Open: Horizontal Split')) + vim.keymap.set('n', 'h', api.node.navigate.parent_close, opts('Close Directory')) +end + +function M.config() + local wk = require('which-key') + wk.register({ + ['e'] = { 'NvimTreeToggle', 'Explorer' }, + }) + + local icons = require('utils.icons') + + require('nvim-tree').setup({ + hijack_netrw = false, + sync_root_with_cwd = true, + on_attach = my_on_attach, + renderer = { + add_trailing = false, + group_empty = false, + highlight_git = false, + full_name = false, + highlight_opened_files = 'none', + root_folder_label = ':t', + indent_width = 2, + indent_markers = { + enable = false, + inline_arrows = true, + icons = { + corner = '└', + edge = '│', + item = '│', + none = ' ', + }, + }, + icons = { + git_placement = 'before', + padding = ' ', + symlink_arrow = ' ➛ ', + glyphs = { + default = icons.ui.Text, + symlink = icons.ui.FileSymlink, + bookmark = icons.ui.BookMark, + folder = { + arrow_closed = icons.ui.ChevronRight, + arrow_open = icons.ui.ChevronShortDown, + default = icons.ui.Folder, + open = icons.ui.FolderOpen, + empty = icons.ui.EmptyFolder, + empty_open = icons.ui.EmptyFolderOpen, + symlink = icons.ui.FolderSymlink, + symlink_open = icons.ui.FolderOpen, + }, + git = { + unstaged = icons.git.FileUnstaged, + staged = icons.git.FileStaged, + unmerged = icons.git.FileUnmerged, + renamed = icons.git.FileRenamed, + untracked = icons.git.FileUntracked, + deleted = icons.git.FileDeleted, + ignored = icons.git.FileIgnored, + }, + }, + }, + special_files = { 'Cargo.toml', 'Makefile', 'README.md', 'readme.md' }, + symlink_destination = true, + }, + update_focused_file = { + enable = true, + debounce_delay = 15, + update_root = true, + ignore_list = {}, + }, + + diagnostics = { + enable = true, + show_on_dirs = false, + show_on_open_dirs = true, + debounce_delay = 50, + severity = { + min = vim.diagnostic.severity.HINT, + max = vim.diagnostic.severity.ERROR, + }, + icons = { + hint = icons.diagnostics.BoldHint, + info = icons.diagnostics.BoldInformation, + warning = icons.diagnostics.BoldWarning, + error = icons.diagnostics.BoldError, + }, + }, + }) +end + +return M diff --git a/lua/custom/plugins/schemastore.lua b/lua/custom/plugins/schemastore.lua new file mode 100644 index 00000000..8bbe2832 --- /dev/null +++ b/lua/custom/plugins/schemastore.lua @@ -0,0 +1,8 @@ +local M = { + 'b0o/schemastore.nvim', + lazy = true, +} + +function M.config() end + +return M diff --git a/lua/custom/plugins/substitute.lua b/lua/custom/plugins/substitute.lua new file mode 100644 index 00000000..a322b0b7 --- /dev/null +++ b/lua/custom/plugins/substitute.lua @@ -0,0 +1,16 @@ +local M = { + 'gbprod/substitute.nvim', + lazy = true, + event = 'VeryLazy', +} + +function M.config() + require('substitute').setup() +end + +vim.api.nvim_set_keymap('n', 's', "lua require('substitute').operator()", { noremap = true }) +vim.api.nvim_set_keymap('n', 'ss', "lua require('substitute').line()", { noremap = true }) +vim.api.nvim_set_keymap('n', 'S', "lua require('substitute').eol()", { noremap = true }) +vim.api.nvim_set_keymap('x', 's', "lua require('substitute').visual()", { noremap = true }) + +return M diff --git a/lua/custom/plugins/surround.lua b/lua/custom/plugins/surround.lua new file mode 100644 index 00000000..6ea19fc6 --- /dev/null +++ b/lua/custom/plugins/surround.lua @@ -0,0 +1,14 @@ +local M = { + 'kylechui/nvim-surround', + version = '*', -- Use for stability; omit to use `main` branch for the latest features + lazy = true, + event = 'VeryLazy', +} + +function M.config() + require('nvim-surround').setup({ + -- Configuration here, or leave empty to use defaults + }) +end + +return M diff --git a/lua/custom/plugins/typescript-tools.lua b/lua/custom/plugins/typescript-tools.lua new file mode 100644 index 00000000..27fbb01f --- /dev/null +++ b/lua/custom/plugins/typescript-tools.lua @@ -0,0 +1,37 @@ +local M = { + 'pmizio/typescript-tools.nvim', + dependencies = { 'nvim-lua/plenary.nvim', 'neovim/nvim-lspconfig' }, + opts = {}, +} + +function M.config() + require('typescript-tools').setup({ + settings = { + -- spawn additional tsserver instance to calculate diagnostics on it + separate_diagnostic_server = true, + -- "change"|"insert_leave" determine when the client asks the server about diagnostic + publish_diagnostic_on = 'insert_leave', + -- array of strings("fix_all"|"add_missing_imports"|"remove_unused") + -- specify commands exposed as code_actions + expose_as_code_action = {}, + -- string|nil - specify a custom path to `tsserver.js` file, if this is nil or file under path + -- not exists then standard path resolution strategy is applied + tsserver_path = nil, + -- specify a list of plugins to load by tsserver, e.g., for support `styled-components` + -- (see 💅 `styled-components` support section) + tsserver_plugins = {}, + -- this value is passed to: https://nodejs.org/api/cli.html#--max-old-space-sizesize-in-megabytes + -- memory limit in megabytes or "auto"(basically no limit) + tsserver_max_memory = 'auto', + -- described below + tsserver_format_options = {}, + tsserver_file_preferences = { + -- importModuleSpecifierPreference = "project-relative", + }, + -- mirror of VSCode's `typescript.suggest.completeFunctionCalls` + complete_function_calls = false, + }, + }) +end + +return M diff --git a/lua/utils/icons.lua b/lua/utils/icons.lua new file mode 100644 index 00000000..e92985c5 --- /dev/null +++ b/lua/utils/icons.lua @@ -0,0 +1,158 @@ +return { + kind = { + Array = ' ', + Boolean = ' ', + Class = ' ', + Color = ' ', + Constant = ' ', + Constructor = ' ', + Enum = ' ', + EnumMember = ' ', + Event = ' ', + Field = ' ', + File = ' ', + Folder = '󰉋 ', + Function = ' ', + Interface = ' ', + Key = ' ', + Keyword = ' ', + Method = ' ', + -- Module = " ", + Module = ' ', + Namespace = ' ', + Null = '󰟢 ', + Number = ' ', + Object = ' ', + Operator = ' ', + Package = ' ', + Property = ' ', + Reference = ' ', + Snippet = ' ', + String = ' ', + Struct = ' ', + Text = ' ', + TypeParameter = ' ', + Unit = ' ', + Value = ' ', + Variable = ' ', + }, + git = { + LineAdded = ' ', + LineModified = ' ', + LineRemoved = ' ', + FileDeleted = ' ', + FileIgnored = '◌', + FileRenamed = ' ', + FileStaged = 'S', + FileUnmerged = '', + FileUnstaged = '', + FileUntracked = 'U', + Diff = ' ', + Repo = ' ', + Octoface = ' ', + Copilot = ' ', + Branch = '', + }, + ui = { + ArrowCircleDown = '', + ArrowCircleLeft = '', + ArrowCircleRight = '', + ArrowCircleUp = '', + BoldArrowDown = '', + BoldArrowLeft = '', + BoldArrowRight = '', + BoldArrowUp = '', + BoldClose = '', + BoldDividerLeft = '', + BoldDividerRight = '', + BoldLineLeft = '▎', + BoldLineMiddle = '┃', + BoldLineDashedMiddle = '┋', + BookMark = '', + BoxChecked = ' ', + Bug = ' ', + Stacks = '', + Scopes = '', + Watches = '󰂥', + DebugConsole = ' ', + Calendar = ' ', + Check = '', + ChevronRight = '', + ChevronShortDown = '', + ChevronShortLeft = '', + ChevronShortRight = '', + ChevronShortUp = '', + Circle = ' ', + Close = '󰅖', + CloudDownload = ' ', + Code = '', + Comment = '', + Dashboard = '', + DividerLeft = '', + DividerRight = '', + DoubleChevronRight = '»', + Ellipsis = '', + EmptyFolder = ' ', + EmptyFolderOpen = ' ', + File = ' ', + FileSymlink = '', + Files = ' ', + FindFile = '󰈞', + FindText = '󰊄', + Fire = '', + Folder = '󰉋 ', + FolderOpen = ' ', + FolderSymlink = ' ', + Forward = ' ', + Gear = ' ', + History = ' ', + Lightbulb = ' ', + LineLeft = '▏', + LineMiddle = '│', + List = ' ', + Lock = ' ', + NewFile = ' ', + Note = ' ', + Package = ' ', + Pencil = '󰏫 ', + Plus = ' ', + Project = ' ', + Search = ' ', + SignIn = ' ', + SignOut = ' ', + Tab = '󰌒 ', + Table = ' ', + Target = '󰀘 ', + Telescope = ' ', + Text = ' ', + Tree = '', + Triangle = '󰐊', + TriangleShortArrowDown = '', + TriangleShortArrowLeft = '', + TriangleShortArrowRight = '', + TriangleShortArrowUp = '', + }, + diagnostics = { + BoldError = '', + Error = '', + BoldWarning = '', + Warning = '', + BoldInformation = '', + Information = '', + BoldQuestion = '', + Question = '', + BoldHint = '', + Hint = '󰌶', + Debug = '', + Trace = '✎', + }, + misc = { + Robot = '󰚩 ', + Squirrel = ' ', + Tag = ' ', + Watch = '', + Smiley = ' ', + Package = ' ', + CircuitBoard = ' ', + }, +} diff --git a/lua/utils/lualine/colors.lua b/lua/utils/lualine/colors.lua new file mode 100644 index 00000000..341d9dbb --- /dev/null +++ b/lua/utils/lualine/colors.lua @@ -0,0 +1,16 @@ +local colors = { + bg = '#202328', + fg = '#bbc2cf', + yellow = '#ECBE7B', + cyan = '#008080', + darkblue = '#081633', + green = '#98be65', + orange = '#FF8800', + violet = '#a9a1e1', + magenta = '#c678dd', + purple = '#c678dd', + blue = '#51afef', + red = '#ec5f67', +} + +return colors diff --git a/lua/utils/lualine/components.lua b/lua/utils/lualine/components.lua new file mode 100644 index 00000000..2cf01be1 --- /dev/null +++ b/lua/utils/lualine/components.lua @@ -0,0 +1,163 @@ +-- +-- This file contains the components that are used in the lualine configuration +-- + +local icons = require('utils.icons') +local conditions = require('utils.lualine.conditions') +local colors = require('utils.lualine.colors') + +return { + branch = { + 'b:gitsigns_head', + icon = icons.git.Branch, + color = { gui = 'bold' }, + }, + filename = { + 'filename', + color = {}, + cond = nil, + }, + diff = { + 'diff', + symbols = { + added = icons.git.LineAdded .. ' ', + modified = icons.git.LineModified .. ' ', + removed = icons.git.LineRemoved .. ' ', + }, + padding = { left = 2, right = 1 }, + diff_color = { + added = { fg = colors.green }, + modified = { fg = colors.yellow }, + removed = { fg = colors.red }, + }, + cond = nil, + }, + diagnostics = { + 'diagnostics', + sources = { 'nvim_diagnostic' }, + symbols = { + error = icons.diagnostics.BoldError .. ' ', + warn = icons.diagnostics.BoldWarning .. ' ', + info = icons.diagnostics.BoldInformation .. ' ', + hint = icons.diagnostics.BoldHint .. ' ', + }, + -- cond = conditions.hide_in_width, + }, + treesitter = { + function() + return icons.ui.Tree + end, + color = function() + local buf = vim.api.nvim_get_current_buf() + local ts = vim.treesitter.highlighter.active[buf] + return { fg = ts and not vim.tbl_isempty(ts) and colors.green or colors.red } + end, + cond = conditions.hide_in_width, + }, + copilot = { + function() + local client = require('copilot.client') + local copilot_active = client.buf_is_attached(vim.api.nvim_get_current_buf()) + -- local buf_clients = vim.lsp.get_active_clients({ bufnr = 0 }) + -- local copilot_active = false + -- + -- -- look for copilot client + -- for _, client in pairs(buf_clients) do + -- if client.name == 'copilot' then + -- copilot_active = true + -- end + -- end + -- + if copilot_active then + return icons.git.Copilot + end + + return '' + end, + color = function() + local api = require('copilot.api') + local status = api.status.data.status + + if status == 'InProgress' then + return { gui = 'bold', fg = colors.yellow } + elseif status == 'Warning' then + return { gui = 'bold', fg = colors.red } + end + + return { gui = 'bold', fg = colors.green } + end, + cond = conditions.hide_in_width, + }, + lsp = { + function() + local buf_clients = vim.lsp.get_active_clients({ bufnr = 0 }) + if #buf_clients == 0 then + return 'LSP Inactive' + end + + local buf_ft = vim.bo.filetype + local buf_client_names = {} + + -- add client + for _, client in pairs(buf_clients) do + if client.name ~= 'null-ls' and client.name ~= 'copilot' then + table.insert(buf_client_names, client.name) + end + end + + -- add formatter + local formatters = require('utils.none-ls.formatters') + local supported_formatters = formatters.list_registered(buf_ft) + vim.list_extend(buf_client_names, supported_formatters) + + -- add linter + local linters = require('utils.none-ls.linters') + local supported_linters = linters.list_registered(buf_ft) + vim.list_extend(buf_client_names, supported_linters) + + local unique_client_names = vim.fn.uniq(buf_client_names) + + local language_servers = '[' .. table.concat(unique_client_names, ', ') .. ']' + + return language_servers + end, + color = { gui = 'bold' }, + cond = conditions.hide_in_width, + }, + location = { 'location' }, + progress = { + 'progress', + fmt = function() + return '%P/%L' + end, + color = {}, + }, + + spaces = { + function() + local shiftwidth = vim.api.nvim_buf_get_option(0, 'shiftwidth') + return icons.ui.Tab .. ' ' .. shiftwidth + end, + padding = 1, + }, + encoding = { + 'o:encoding', + fmt = string.upper, + color = {}, + cond = conditions.hide_in_width, + }, + filetype = { 'filetype', cond = nil, padding = { left = 1, right = 1 } }, + scrollbar = { + function() + local current_line = vim.fn.line('.') + local total_lines = vim.fn.line('$') + local chars = { '__', '▁▁', '▂▂', '▃▃', '▄▄', '▅▅', '▆▆', '▇▇', '██' } + local line_ratio = current_line / total_lines + local index = math.ceil(line_ratio * #chars) + return chars[index] + end, + padding = { left = 0, right = 0 }, + color = 'SLProgress', + cond = nil, + }, +} diff --git a/lua/utils/lualine/conditions.lua b/lua/utils/lualine/conditions.lua new file mode 100644 index 00000000..a55d8b00 --- /dev/null +++ b/lua/utils/lualine/conditions.lua @@ -0,0 +1,17 @@ +local window_width_limit = 100 + +local conditions = { + buffer_not_empty = function() + return vim.fn.empty(vim.fn.expand('%:t')) ~= 1 + end, + hide_in_width = function() + return vim.o.columns > window_width_limit + end, + -- check_git_workspace = function() + -- local filepath = vim.fn.expand "%:p:h" + -- local gitdir = vim.fn.finddir(".git", filepath .. ";") + -- return gitdir and #gitdir > 0 and #gitdir < #filepath + -- end, +} + +return conditions diff --git a/lua/utils/none-ls/formatters.lua b/lua/utils/none-ls/formatters.lua new file mode 100644 index 00000000..dbfd741c --- /dev/null +++ b/lua/utils/none-ls/formatters.lua @@ -0,0 +1,31 @@ +local M = {} + +local null_ls = require('null-ls') +local services = require('utils.none-ls.services') +local method = null_ls.methods.FORMATTING + +function M.list_registered(filetype) + local registered_providers = services.list_registered_providers_names(filetype) + return registered_providers[method] or {} +end + +function M.list_supported(filetype) + local s = require('null-ls.sources') + local supported_formatters = s.get_supported(filetype, 'formatting') + table.sort(supported_formatters) + return supported_formatters +end + +function M.setup(formatter_configs) + if vim.tbl_isempty(formatter_configs) then + return + end + + local registered = services.register_sources(formatter_configs, method) + + if #registered > 0 then + vim.notify('Registered the following formatters: ' .. unpack(registered), vim.log.levels.DEBUG) + end +end + +return M diff --git a/lua/utils/none-ls/linters.lua b/lua/utils/none-ls/linters.lua new file mode 100644 index 00000000..9ab66d1f --- /dev/null +++ b/lua/utils/none-ls/linters.lua @@ -0,0 +1,41 @@ +local M = {} + +local null_ls = require('null-ls') +local services = require('utils.none-ls.services') +local method = null_ls.methods.DIAGNOSTICS + +local alternative_methods = { + null_ls.methods.DIAGNOSTICS, + null_ls.methods.DIAGNOSTICS_ON_OPEN, + null_ls.methods.DIAGNOSTICS_ON_SAVE, +} + +function M.list_registered(filetype) + local registered_providers = services.list_registered_providers_names(filetype) + local providers_for_methods = vim.tbl_flatten(vim.tbl_map(function(m) + return registered_providers[m] or {} + end, alternative_methods)) + + return providers_for_methods +end + +function M.list_supported(filetype) + local s = require('null-ls.sources') + local supported_linters = s.get_supported(filetype, 'diagnostics') + table.sort(supported_linters) + return supported_linters +end + +function M.setup(linter_configs) + if vim.tbl_isempty(linter_configs) then + return + end + + local registered = services.register_sources(linter_configs, method) + + if #registered > 0 then + vim.notify('Registered the following linters: ' .. unpack(registered), vim.log.levels.DEBUG) + end +end + +return M diff --git a/lua/utils/none-ls/services.lua b/lua/utils/none-ls/services.lua new file mode 100644 index 00000000..4fadcefb --- /dev/null +++ b/lua/utils/none-ls/services.lua @@ -0,0 +1,56 @@ +local M = {} + +function M.list_registered_providers_names(filetype) + local s = require('null-ls.sources') + local available_sources = s.get_available(filetype) + local registered = {} + for _, source in ipairs(available_sources) do + for method in pairs(source.methods) do + registered[method] = registered[method] or {} + table.insert(registered[method], source.name) + end + end + return registered +end + +function M.register_sources(configs, method) + local null_ls = require('null-ls') + local is_registered = require('null-ls.sources').is_registered + + local sources, registered_names = {}, {} + + for _, config in ipairs(configs) do + local cmd = config.exe or config.command + local name = config.name or cmd:gsub('-', '_') + local type = method == null_ls.methods.CODE_ACTION and 'code_actions' or null_ls.methods[method]:lower() + local source = type and null_ls.builtins[type][name] + vim.notify(string.format('Received request to register [%s] as a %s source', name, type), vim.log.levels.DEBUG) + if not source then + vim.notify('Not a valid source: ' .. name, vim.log.levels.ERROR) + elseif is_registered({ name = source.name or name, method = method }) then + vim.notify(string.format('Skipping registering [%s] more than once', name), vim.log.levels.TRACE) + else + local command = M.find_command(source._opts.command) or source._opts.command + + -- treat `args` as `extra_args` for backwards compatibility. Can otherwise use `generator_opts.args` + local compat_opts = vim.deepcopy(config) + if config.args then + compat_opts.extra_args = config.args or config.extra_args + compat_opts.args = nil + end + + local opts = vim.tbl_deep_extend('keep', { command = command }, compat_opts) + vim.notify('Registering source ' .. name, vim.log.levels.DEBUG) + vim.notify(vim.inspect(opts), vim.log.levels.TRACE) + table.insert(sources, source.with(opts)) + vim.list_extend(registered_names, { source.name }) + end + end + + if #sources > 0 then + null_ls.register({ sources = sources }) + end + return registered_names +end + +return M