From 9fb993f9dabb723af5fb33b83128c5fbcad83afb Mon Sep 17 00:00:00 2001 From: David Bell Date: Mon, 3 Apr 2023 21:19:33 +0100 Subject: [PATCH] feat(nvim pluigins): new nvim custom plugins --- lua/custom/plugins/autopairs.lua | 8 ++++ lua/custom/plugins/filetree.lua | 15 ++++++ lua/custom/plugins/octo.lua | 32 +++++++++++++ lua/custom/plugins/op.lua | 79 ++++++++++++++++++++++++++++++++ 4 files changed, 134 insertions(+) create mode 100644 lua/custom/plugins/autopairs.lua create mode 100644 lua/custom/plugins/filetree.lua create mode 100644 lua/custom/plugins/octo.lua create mode 100644 lua/custom/plugins/op.lua diff --git a/lua/custom/plugins/autopairs.lua b/lua/custom/plugins/autopairs.lua new file mode 100644 index 00000000..cd5931d4 --- /dev/null +++ b/lua/custom/plugins/autopairs.lua @@ -0,0 +1,8 @@ +-- File: lua/custom/plugins/autopairs.lua + +return { + "windwp/nvim-autopairs", + config = function() + require("nvim-autopairs").setup {} + end, +} diff --git a/lua/custom/plugins/filetree.lua b/lua/custom/plugins/filetree.lua new file mode 100644 index 00000000..55580ad2 --- /dev/null +++ b/lua/custom/plugins/filetree.lua @@ -0,0 +1,15 @@ +-- Unless you are still migrating, remove the deprecated commands from v1.x +vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]]) + +return { + "nvim-neo-tree/neo-tree.nvim", + version = "*", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended + "MunifTanjim/nui.nvim", + }, + config = function () + require('neo-tree').setup {} + end, +} diff --git a/lua/custom/plugins/octo.lua b/lua/custom/plugins/octo.lua new file mode 100644 index 00000000..28e7c8e8 --- /dev/null +++ b/lua/custom/plugins/octo.lua @@ -0,0 +1,32 @@ + +return { + 'pwntester/octo.nvim', + version = "*", + dependencies = { + -- 1Password plugin for Neovim + 'mrjones2014/op.nvim', + -- another plugin to make the UI a bit nicer + 'stevearc/dressing.nvim', + }, + config = function () + require('octo').setup({ + gh_env = function() + -- the 'op.api' module provides the same interface as the CLI + -- each subcommand accepts a list of arguments + -- and returns a list of output lines. + -- use it to retrieve the GitHub access token from 1Password + local github_token = require('op.api').item.get({ 'GitHub', '--fields', 'token' })[1] + if not github_token or not vim.startswith(github_token, 'ghp_') then + error('Failed to get GitHub token.') + end + + -- the values in this table will be provided to the + -- GitHub CLI as environment variables when invoked, + -- with the table keys (e.g. GITHUB_TOKEN) being the + -- environment variable name, and the values (e.g. github_token) + -- being the variable value + return { GITHUB_TOKEN = github_token } + end, + }) + end, +} diff --git a/lua/custom/plugins/op.lua b/lua/custom/plugins/op.lua new file mode 100644 index 00000000..b9777d57 --- /dev/null +++ b/lua/custom/plugins/op.lua @@ -0,0 +1,79 @@ + +return { + 'mrjones2014/op.nvim', + version = "*", + config = function () + require('op').setup({ + -- you can change this to a full path if `op` + -- is not on your $PATH + op_cli_path = 'op', + -- Whether to sign in on start. + signin_on_start = false, + -- show NerdFont icons in `vim.ui.select()` interfaces, + -- set to false if you do not use a NerdFont or just + -- don't want icons + use_icons = true, + -- command to use for opening URLs, + -- can be a function or a string + url_open_command = function() + if vim.fn.has('mac') == 1 then + return 'open' + elseif vim.fn.has('unix') == 1 then + return 'xdg-open' + end + return nil + end, + -- settings for op.nvim sidebar + sidebar = { + -- sections to include in the sidebar + sections = { + favorites = true, + secure_notes = true, + }, + -- sidebar width + width = 40, + -- put the sidebar on the right or left side + side = 'right', + -- keymappings for the sidebar buffer. + -- can be a string mapping to a function from + -- the module `op.sidebar.actions`, + -- an editor command string, or a function. + -- if you supply a function, a table with the following + -- fields will be passed as an argument: + -- { + -- title: string, + -- icon: string, + -- type: 'header' | 'item' + -- -- data will be nil if type == 'header' + -- data: nil | { + -- uuid: string, + -- vault_uuid: string, + -- category: string, + -- url: string + -- } + -- } + mappings = { + -- if it's a Secure Note, open in op.nvim's Secure Notes editor; + -- if it's an item with a URL, open & fill the item in default browser; + -- otherwise, open in 1Password 8 desktop app + [''] = 'default_open', + -- open in 1Password 8 desktop app + ['go'] = 'open_in_desktop_app', + -- edit in 1Password 8 desktop app + ['ge'] = 'edit_in_desktop_app', + }, + }, + -- Custom formatter function for statusline component + statusline_fmt = function(account_name) + if not account_name or #account_name == 0 then + return '> 1Password: No active session' + end + + return string.format('> 1Password: %s', account_name) + end + -- global_args accepts any arguments + -- listed under "Global Flags" in + -- `op --help` output. + }) + end, +}