From 2ed61e53638b003b2225fc996a531bc2d4aa0da4 Mon Sep 17 00:00:00 2001 From: Rahsheen Porter Date: Sun, 25 Feb 2024 23:08:19 -0500 Subject: [PATCH] add subtree for kickstart.nvim --- after/plugin/defaults.lua | 2 + after/plugin/lualine.lua | 13 +++++++ after/plugin/null-ls.lua | 75 +++++++++++++++++++++++++++++++++++++ init.lua | 6 +-- lazy-lock.json | 34 +++++++++++++++++ lua/custom/plugins/init.lua | 59 ++++++++++++++++++++++++++--- lua/rahcodes/keymap.lua | 20 ++++++++++ lua/rahcodes/remap.lua | 69 ++++++++++++++++++++++++++++++++++ lua/rahcodes/sets.lua | 26 +++++++++++++ 9 files changed, 296 insertions(+), 8 deletions(-) create mode 100644 after/plugin/defaults.lua create mode 100644 after/plugin/lualine.lua create mode 100644 after/plugin/null-ls.lua create mode 100644 lazy-lock.json create mode 100644 lua/rahcodes/keymap.lua create mode 100644 lua/rahcodes/remap.lua create mode 100644 lua/rahcodes/sets.lua diff --git a/after/plugin/defaults.lua b/after/plugin/defaults.lua new file mode 100644 index 00000000..dd0ba5b2 --- /dev/null +++ b/after/plugin/defaults.lua @@ -0,0 +1,2 @@ +require("rahcodes.remap") +require("rahcodes.sets") diff --git a/after/plugin/lualine.lua b/after/plugin/lualine.lua new file mode 100644 index 00000000..1e3a426e --- /dev/null +++ b/after/plugin/lualine.lua @@ -0,0 +1,13 @@ +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 new file mode 100644 index 00000000..12d5b500 --- /dev/null +++ b/after/plugin/null-ls.lua @@ -0,0 +1,75 @@ +local setup, null_ls = pcall(require, "null-ls") +if not setup then + return +end + +local formatting = null_ls.builtins.formatting +local diagnostics = null_ls.builtins.diagnostics +local conditional = function(fn) + 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, + }) +end + +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 + }), + + -- 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, +}) diff --git a/init.lua b/init.lua index fd4567d9..f23e6682 100644 --- a/init.lua +++ b/init.lua @@ -282,7 +282,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 ]] @@ -424,7 +424,7 @@ local function telescope_live_grep_open_files() end 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', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]les' }) 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' }) @@ -590,7 +590,7 @@ local servers = { -- gopls = {}, -- pyright = {}, -- rust_analyzer = {}, - -- tsserver = {}, + tsserver = {}, -- html = { filetypes = { 'html', 'twig', 'hbs'} }, lua_ls = { diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 00000000..f5a1768f --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,34 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, + "LuaSnip": { "branch": "master", "commit": "f3b3d3446bcbfa62d638b1903ff00a78b2b730a1" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "fidget.nvim": { "branch": "main", "commit": "60404ba67044c6ab01894dd5bf77bd64ea5e09aa" }, + "friendly-snippets": { "branch": "main", "commit": "dcd4a586439a1c81357d5b9d26319ae218cc9479" }, + "git-worktree.nvim": { "branch": "master", "commit": "f247308e68dab9f1133759b05d944569ad054546" }, + "gitsigns.nvim": { "branch": "main", "commit": "2c2463dbd82eddd7dbab881c3a62cfbfbe3c67ae" }, + "indent-blankline.nvim": { "branch": "master", "commit": "821a7acd88587d966f7e464b0b3031dfe7f5680c" }, + "lazy.nvim": { "branch": "main", "commit": "aedcd79811d491b60d0a6577a9c1701063c2a609" }, + "lualine.nvim": { "branch": "master", "commit": "7d131a8d3ba5016229e8a1d08bf8782acea98852" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "21d33d69a81f6351e5a5f49078b2e4f0075c8e73" }, + "mason.nvim": { "branch": "main", "commit": "3b5068f0fc565f337d67a2d315d935f574848ee7" }, + "neodev.nvim": { "branch": "main", "commit": "3157f2e876fd6223d36cfa76bee4709247d62fa5" }, + "null-ls.nvim": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" }, + "nvim-cmp": { "branch": "main", "commit": "04e0ca376d6abdbfc8b52180f8ea236cbfddf782" }, + "nvim-lspconfig": { "branch": "master", "commit": "ec7d51a619049c7c597f469f81ea199db6794651" }, + "nvim-surround": { "branch": "main", "commit": "703ec63aa798e5e07d309b35e42def34bebe0174" }, + "nvim-treesitter": { "branch": "master", "commit": "6e2b56cbe75ddf18e6efecee44bc3936d70b0b3e" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "7f00d94543f1fd37cab2afa2e9a6cd54e1c6b9ef" }, + "onedark.nvim": { "branch": "master", "commit": "1230aaf2a427b2c5b73aba6e4a9a5881d3e69429" }, + "plenary.nvim": { "branch": "master", "commit": "4f71c0c4a196ceb656c824a70792f3df3ce6bb6d" }, + "refactoring.nvim": { "branch": "master", "commit": "1b593e7203b31c7bde3fa638e6869144698df3b6" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, + "telescope.nvim": { "branch": "0.1.x", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, + "tokyonight.nvim": { "branch": "main", "commit": "610179f7f12db3d08540b6cc61434db2eaecbcff" }, + "trouble.nvim": { "branch": "main", "commit": "f1168feada93c0154ede4d1fe9183bf69bac54ea" }, + "vim-fugitive": { "branch": "master", "commit": "2e88f14a585c014691904ba8fe39e6ea851c9422" }, + "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/plugins/init.lua b/lua/custom/plugins/init.lua index be0eb9d8..98ba2bac 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -1,5 +1,54 @@ --- You can add your own plugins here or in other files in this directory! --- I promise not to create any merge conflicts in this directory :) --- --- See the kickstart.nvim README for more information -return {} +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, + }, +} diff --git a/lua/rahcodes/keymap.lua b/lua/rahcodes/keymap.lua new file mode 100644 index 00000000..463c1881 --- /dev/null +++ b/lua/rahcodes/keymap.lua @@ -0,0 +1,20 @@ +local M = {} + +local function bind(op, outer_opts) + outer_opts = outer_opts or {noremap = true} + return function(lhs, rhs, opts) + opts = vim.tbl_extend("force", + outer_opts, + opts or {} + ) + vim.keymap.set(op, lhs,rhs, opts) + end +end + +M.nmap = bind("n", {noremap = false}) +M.nnoremap = bind("n") +M.vnoremap = bind("v") +M.xnoremap = bind("x") +M.inoremap = bind("i") + +return M diff --git a/lua/rahcodes/remap.lua b/lua/rahcodes/remap.lua new file mode 100644 index 00000000..e315af27 --- /dev/null +++ b/lua/rahcodes/remap.lua @@ -0,0 +1,69 @@ +local Remap = require("rahcodes.keymap") +local nmap = Remap.nmap + +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("n", "", "zz") +vim.keymap.set("n", "", "zz") + +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("i", "", "") + +-- vim.keymap.set("n", "/", "/\v") +-- vim.keymap.set("v", "/", "/\v") +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", "", "") + +-- No weird line jumps +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", "", "silent !tmux neww tmux-sessionizer") + +-- Move buffers +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") + +-- Save +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" }) + +-- 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) diff --git a/lua/rahcodes/sets.lua b/lua/rahcodes/sets.lua new file mode 100644 index 00000000..2cf4c156 --- /dev/null +++ b/lua/rahcodes/sets.lua @@ -0,0 +1,26 @@ +vim.opt.guicursor = "" + +vim.opt.nu = true +vim.opt.relativenumber = true + +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true + +vim.opt.smartindent = true + +vim.opt.wrap = false + +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" + +vim.opt.incsearch = true + +vim.opt.scrolloff = 8 +vim.opt.isfname:append("@-@") + +vim.opt.colorcolumn = "80" + +vim.opt.mouse = "v"