From b88bb9ed6ec50c4ecc8e7063c2f88de347efae34 Mon Sep 17 00:00:00 2001 From: Rahsheen Porter Date: Sun, 3 Mar 2024 21:44:34 -0500 Subject: [PATCH] fix up broken junk and snippets --- after/plugin/lualine.lua | 13 ---- after/plugin/null-ls.lua | 118 ++++++++++++++--------------- after/plugin/telescope.lua | 2 - init.lua | 6 +- lua/custom/plugins/init.lua | 144 +++++++++++++++++++----------------- lua/rahcodes/remap.lua | 94 +++++++++++++---------- 6 files changed, 193 insertions(+), 184 deletions(-) delete mode 100644 after/plugin/lualine.lua delete mode 100644 after/plugin/telescope.lua diff --git a/after/plugin/lualine.lua b/after/plugin/lualine.lua deleted file mode 100644 index 1e3a426e..00000000 --- a/after/plugin/lualine.lua +++ /dev/null @@ -1,13 +0,0 @@ -require("lualine").setup({ - options = { - theme = "tokyonight", - tabline = { - lualine_a = { "buffers" }, - lualine_b = { "branch" }, - lualine_c = { "filename" }, - lualine_x = {}, - lualine_y = {}, - lualine_z = { "tabs" }, - }, - }, -}) diff --git a/after/plugin/null-ls.lua b/after/plugin/null-ls.lua index 12d5b500..1e6c5892 100644 --- a/after/plugin/null-ls.lua +++ b/after/plugin/null-ls.lua @@ -1,75 +1,75 @@ -local setup, null_ls = pcall(require, "null-ls") +local setup, null_ls = pcall(require, 'null-ls') if not setup then - return + return end local formatting = null_ls.builtins.formatting -local diagnostics = null_ls.builtins.diagnostics +-- local diagnostics = null_ls.builtins.diagnostics local conditional = function(fn) - local utils = require("null-ls.utils").make_conditional_utils() - return fn(utils) + local utils = require('null-ls.utils').make_conditional_utils() + return fn(utils) end local lsp_formatting = function(bufnr) - vim.lsp.buf.format({ - timeout_ms = 2000, - filter = function(client) - -- apply whatever logic you want (in this example, we'll only use null-ls) - return client.name ~= "tsserver" - end, - bufnr = bufnr, - }) + vim.lsp.buf.format { + timeout_ms = 2000, + filter = function(client) + -- apply whatever logic you want (in this example, we'll only use null-ls) + return client.name ~= 'tsserver' + end, + bufnr = bufnr, + } end -local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) +local augroup = vim.api.nvim_create_augroup('LspFormatting', {}) -- local my_rubocop_formatter = require("rahcodes.null-ls.rubocop") local rubocop = null_ls.builtins.formatting.rubocop -null_ls.setup({ - debug = false, - sources = { - formatting.prettier, - -- formatting.stylua, - null_ls.builtins.code_actions.gitsigns, - -- setting eslint_d only if we have a ".eslintrc.js" file in the project - diagnostics.eslint_d.with({ - condition = function(utils) - return utils.root_has_file({ '.eslintrc.js' }) - end - }), +null_ls.setup { + debug = false, + sources = { + formatting.prettier, + -- formatting.stylua, + null_ls.builtins.code_actions.gitsigns, + -- setting eslint_d only if we have a ".eslintrc.js" file in the project + -- diagnostics.eslint_d.with { + -- condition = function(utils) + -- return utils.root_has_file { '.eslintrc', '.eslintrc.js', '.eslintrc.json' } + -- end, + -- }, - -- Here we set a conditional to call the rubocop formatter. If we have a Gemfile in the project, we call "bundle exec rubocop", if not we only call "rubocop". - conditional(function(utils) - return utils.root_has_file("Gemfile") - and rubocop.with({ - command = "bundle", - args = vim.list_extend({ "exec", "rubocop" }, rubocop._opts.args), - }) - or rubocop - end), + -- Here we set a conditional to call the rubocop formatter. If we have a Gemfile in the project, we call "bundle exec rubocop", if not we only call "rubocop". + conditional(function(utils) + return utils.root_has_file 'Gemfile' + and rubocop.with { + command = 'bundle', + args = vim.list_extend({ 'exec', 'rubocop' }, rubocop._opts.args), + } + or rubocop + end), - -- Same as above, but with diagnostics.rubocop to make sure we use the proper rubocop version for the project - conditional(function(utils) - return utils.root_has_file("Gemfile") - and null_ls.builtins.diagnostics.rubocop.with({ - command = "bundle", - args = vim.list_extend({ "exec", "rubocop" }, null_ls.builtins.diagnostics.rubocop._opts.args), - }) - or null_ls.builtins.diagnostics.rubocop - end), - }, - -- format on save - on_attach = function(client, bufnr) - if client.supports_method("textDocument/formatting") then - vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) - vim.api.nvim_create_autocmd("BufWritePre", { - group = augroup, - buffer = bufnr, - callback = function() - lsp_formatting(bufnr) - end, - }) - end - end, -}) + -- Same as above, but with diagnostics.rubocop to make sure we use the proper rubocop version for the project + conditional(function(utils) + return utils.root_has_file 'Gemfile' + and null_ls.builtins.diagnostics.rubocop.with { + command = 'bundle', + args = vim.list_extend({ 'exec', 'rubocop' }, null_ls.builtins.diagnostics.rubocop._opts.args), + } + or null_ls.builtins.diagnostics.rubocop + end), + }, + -- format on save + on_attach = function(client, bufnr) + if client.supports_method 'textDocument/formatting' then + vim.api.nvim_clear_autocmds { group = augroup, buffer = bufnr } + vim.api.nvim_create_autocmd('BufWritePre', { + group = augroup, + buffer = bufnr, + callback = function() + lsp_formatting(bufnr) + end, + }) + end + end, +} diff --git a/after/plugin/telescope.lua b/after/plugin/telescope.lua deleted file mode 100644 index e6613cf4..00000000 --- a/after/plugin/telescope.lua +++ /dev/null @@ -1,2 +0,0 @@ -pcall(require("telescope").load_extension, "ui-select") -pcall(require("telescope").load_extension, "live_grep_args") diff --git a/init.lua b/init.lua index 292ec077..23e8e885 100644 --- a/init.lua +++ b/init.lua @@ -652,7 +652,7 @@ require('lazy').setup { -- you can use this plugin to help you. It even has snippets -- for various frameworks/libraries/etc. but you will have to -- set up the ones that are useful for you. - -- 'rafamadriz/friendly-snippets', + 'rafamadriz/friendly-snippets', }, config = function() -- See `:help cmp` @@ -806,7 +806,7 @@ require('lazy').setup { -- Here are some example plugins that I've included in the kickstart repository. -- Uncomment any of the lines below to enable them (you will need to restart nvim). -- - -- require 'kickstart.plugins.debug', + require 'kickstart.plugins.debug', -- require 'kickstart.plugins.indent_line', -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` @@ -814,7 +814,7 @@ require('lazy').setup { -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, } -- The line beneath this is called `modeline`. See `:help modeline` diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index 257f9b3f..618de753 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -1,68 +1,80 @@ return { - { - "ThePrimeagen/refactoring.nvim", - requires = { - { "nvim-lua/plenary.nvim" }, - { "nvim-treesitter/nvim-treesitter" }, - }, - config = function() - require("refactoring").setup({}) - end, - }, - { - "ThePrimeagen/git-worktree.nvim", - }, - { - "folke/tokyonight.nvim", - lazy = false, -- make sure we load this during startup if it is your main colorscheme - priority = 1000, -- make sure to load this before all the other start plugins - config = function() - -- load the colorscheme here - vim.cmd([[colorscheme tokyonight]]) - end, - }, - -- formatting & linting - "jose-elias-alvarez/null-ls.nvim", - -- use("jayp0521/mason-null-ls.nvim") - { - "kylechui/nvim-surround", - version = "*", -- Use for stability; omit to use `main` branch for the latest features - event = "VeryLazy", - config = function() - require("nvim-surround").setup({ - -- Configuration here, or leave empty to use defaults - }) - end, - }, - { - "folke/trouble.nvim", - requires = "nvim-tree/nvim-web-devicons", - config = function() - require("trouble").setup({ - -- your configuration comes here - -- or leave it empty to use the default settings - -- refer to the configuration section below - }) - end, - }, - { - "rafamadriz/friendly-snippets", - config = function() - require("luasnip.loaders.from_vscode").lazy_load() - end, - }, - { - "nvim-telescope/telescope.nvim", - dependencies = { - { - "nvim-telescope/telescope-live-grep-args.nvim", - -- This will not install any breaking changes. - -- For major updates, this must be adjusted manually. - version = "^1.0.0", - }, - }, - config = function() - require("telescope").load_extension("live_grep_args") - end - } + { + 'ThePrimeagen/refactoring.nvim', + requires = { + { 'nvim-lua/plenary.nvim' }, + { 'nvim-treesitter/nvim-treesitter' }, + }, + config = function() + require('refactoring').setup {} + end, + }, + { + 'ThePrimeagen/git-worktree.nvim', + }, + { + 'folke/tokyonight.nvim', + lazy = false, -- make sure we load this during startup if it is your main colorscheme + priority = 1000, -- make sure to load this before all the other start plugins + config = function() + -- load the colorscheme here + vim.cmd [[colorscheme tokyonight]] + end, + }, + -- formatting & linting + 'jose-elias-alvarez/null-ls.nvim', + -- use("jayp0521/mason-null-ls.nvim") + { + 'kylechui/nvim-surround', + version = '*', -- Use for stability; omit to use `main` branch for the latest features + event = 'VeryLazy', + config = function() + require('nvim-surround').setup { + -- Configuration here, or leave empty to use defaults + } + end, + }, + { + 'folke/trouble.nvim', + requires = 'nvim-tree/nvim-web-devicons', + config = function() + require('trouble').setup { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + } + end, + }, + { + 'rafamadriz/friendly-snippets', + config = function() + require('luasnip.loaders.from_vscode').lazy_load() + end, + }, + { -- Fuzzy Finder (files, lsp, etc) + 'nvim-telescope/telescope.nvim', + dependencies = { + { + 'nvim-telescope/telescope-live-grep-args.nvim', + -- This will not install any breaking changes. + -- For major updates, this must be adjusted manually. + version = '^1.0.0', + keys = { + { 'sga', ":lua require('telescope').extensions.live_grep_args.live_grep_args()", desc = 'Live Grep (Args)' }, + }, + config = function() + require('telescope').load_extension 'live_grep_args' + end, + }, + }, + }, + { + 'tpope/vim-fugitive', + dependencies = { { 'tpope/vim-rhubarb' } }, + }, + { + 'pmizio/typescript-tools.nvim', + dependencies = { 'nvim-lua/plenary.nvim', 'neovim/nvim-lspconfig' }, + opts = {}, + }, } diff --git a/lua/rahcodes/remap.lua b/lua/rahcodes/remap.lua index e315af27..bbfffa6b 100644 --- a/lua/rahcodes/remap.lua +++ b/lua/rahcodes/remap.lua @@ -1,69 +1,81 @@ -local Remap = require("rahcodes.keymap") +local Remap = require 'rahcodes.keymap' local nmap = Remap.nmap -vim.keymap.set("n", "pv", vim.cmd.Ex) +vim.keymap.set('n', 'pv', vim.cmd.Ex) -vim.keymap.set("v", "J", ":m '>+1gv=gv") -vim.keymap.set("v", "K", ":m '<-2gv=gv") +vim.keymap.set('v', 'J', ":m '>+1gv=gv") +vim.keymap.set('v', 'K', ":m '<-2gv=gv") -vim.keymap.set("n", "", "zz") -vim.keymap.set("n", "", "zz") +vim.keymap.set('n', '', 'zz') +vim.keymap.set('n', '', 'zz') -vim.keymap.set("n", "n", "nzzzv") -vim.keymap.set("n", "N", "Nzzzv") +vim.keymap.set('n', 'n', 'nzzzv') +vim.keymap.set('n', 'N', 'Nzzzv') -- don't bork paste buffer when pasting -vim.keymap.set("x", "p", '"_dP') +vim.keymap.set('x', 'p', '"_dP') -vim.keymap.set("i", "", "") +vim.keymap.set('i', '', '') -- vim.keymap.set("n", "/", "/\v") -- vim.keymap.set("v", "/", "/\v") -vim.keymap.set("n", "`", ":noh") +vim.keymap.set('n', '`', ':noh') -- No Cheating -vim.keymap.set("n", "", "") -vim.keymap.set("n", "", "") -vim.keymap.set("n", "", "") -vim.keymap.set("n", "", "") -vim.keymap.set("i", "", "") -vim.keymap.set("i", "", "") -vim.keymap.set("i", "", "") -vim.keymap.set("i", "", "") +vim.keymap.set('n', '', '') +vim.keymap.set('n', '', '') +vim.keymap.set('n', '', '') +vim.keymap.set('n', '', '') +vim.keymap.set('i', '', '') +vim.keymap.set('i', '', '') +vim.keymap.set('i', '', '') +vim.keymap.set('i', '', '') -- No weird line jumps -vim.keymap.set("n", "j", "gj") -vim.keymap.set("n", "k", "gk") +vim.keymap.set('n', 'j', 'gj') +vim.keymap.set('n', 'k', 'gk') -- Copy to system clipboard -vim.keymap.set("n", "y", '"*y') -vim.keymap.set("v", "y", '"*y') -vim.keymap.set("n", "yy", '"+y') -vim.keymap.set("v", "yy", '"+y') +vim.keymap.set('n', 'y', '"*y') +vim.keymap.set('v', 'y', '"*y') +vim.keymap.set('n', 'yy', '"+y') +vim.keymap.set('v', 'yy', '"+y') -vim.keymap.set("n", "", "silent !tmux neww tmux-sessionizer") +vim.keymap.set('n', '', 'silent !tmux neww tmux-sessionizer') -- Move buffers -nmap("sp", ":bprev") -nmap("sn", ":bnext") +nmap('sp', ':bprev') +nmap('sn', ':bnext') -- Quickfix list navigation -vim.keymap.set("n", "", "cnextzz") -vim.keymap.set("n", "", "cprevzz") -vim.keymap.set("n", "k", "lnextzz") -vim.keymap.set("n", "j", "lprevzz") +vim.keymap.set('n', '', 'cnextzz') +vim.keymap.set('n', '', 'cprevzz') +vim.keymap.set('n', 'k', 'lnextzz') +vim.keymap.set('n', 'j', 'lprevzz') -- Save -nmap("", ":wa") +nmap('', ':wa') -- See `:help telescope.builtin` -vim.keymap.set("n", "m", require("telescope.builtin").oldfiles, { desc = "[?] Find recently opened files" }) -vim.keymap.set("n", "/", require("telescope.builtin").find_files, { desc = "[S]earch [F]iles" }) +vim.keymap.set('n', 'm', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) +vim.keymap.set('n', '/', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) -- Trouble bindings -vim.keymap.set("n", "xx", function() require("trouble").open() end) -vim.keymap.set("n", "xw", function() require("trouble").open("workspace_diagnostics") end) -vim.keymap.set("n", "xd", function() require("trouble").open("document_diagnostics") end) -vim.keymap.set("n", "xq", function() require("trouble").open("quickfix") end) -vim.keymap.set("n", "xl", function() require("trouble").open("loclist") end) -vim.keymap.set("n", "gR", function() require("trouble").open("lsp_references") end) +vim.keymap.set('n', 'xx', function() + require('trouble').open() +end) +vim.keymap.set('n', 'xw', function() + require('trouble').open 'workspace_diagnostics' +end) +vim.keymap.set('n', 'xd', function() + require('trouble').open 'document_diagnostics' +end) +vim.keymap.set('n', 'xq', function() + require('trouble').open 'quickfix' +end) +vim.keymap.set('n', 'xl', function() + require('trouble').open 'loclist' +end) +vim.keymap.set('n', 'gR', function() + require('trouble').open 'lsp_references' +end)