From e1375562508a57ed88ce76c0d9273a81c03a4a6a Mon Sep 17 00:00:00 2001 From: Garrett Dawson Date: Sat, 18 Mar 2023 22:47:34 -0600 Subject: [PATCH] Fork and customize config --- after/plugin/defaults.lua | 70 ++++++++++++++++++++++++++++ init.lua | 53 +++++++++++---------- lua/custom/plugins/init.lua | 31 ++++++++++-- lua/custom/plugins/nvim-base16.lua | 10 ++++ lua/custom/plugins/reveal.lua | 20 ++++++++ lua/kickstart/plugins/autoformat.lua | 6 +-- 6 files changed, 155 insertions(+), 35 deletions(-) create mode 100644 after/plugin/defaults.lua create mode 100644 lua/custom/plugins/nvim-base16.lua create mode 100644 lua/custom/plugins/reveal.lua diff --git a/after/plugin/defaults.lua b/after/plugin/defaults.lua new file mode 100644 index 00000000..ef1ce4e8 --- /dev/null +++ b/after/plugin/defaults.lua @@ -0,0 +1,70 @@ +-- prev/next tab +vim.keymap.set('n', 'H', 'gT') +vim.keymap.set('n', 'L', 'gt') + +-- line bubbling + +-- nnoremap :m .+1== +-- nnoremap :m .-2== +vim.keymap.set('n', '', ':m .+1==', { noremap = true }) +vim.keymap.set('n', '', ':m .-2==', { noremap = true }) -- conflicts with "signature help" from LSP + +-- inoremap :m .+1==gi +-- inoremap :m .-2==gi +vim.keymap.set('i', '', ':m .+1==gi', { noremap = true }) +vim.keymap.set('i', '', ':m .-2==gi', { noremap = true }) + +-- vnoremap :m '>+1gv=gv +-- vnoremap :m '<-2gv=gv +vim.keymap.set('v', '', ":m '<-2gv=gv", { noremap = true }) +vim.keymap.set('v', '', ":m '>+1gv=gv", { noremap = true }) + +vim.o.inccommand = "nosplit" + +-- vim.cmd([[ +-- autocmd FileType dirvish nmap - +-- ]]) + +vim.diagnostic.config({ + virtual_text = { + -- source = "always", -- Or "if_many" + prefix = '●', -- Could be '■', '▎', 'x' + }, + severity_sort = true, + float = { + source = "always", -- Or "if_many" + }, +}) +-- vim.o.updatetime = 250 +-- vim.cmd [[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]] + + +local signs = { Error = "✗", Warn = "⚠", Hint = "➤", Info = "i" } +for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) +end + + +-- function PrintDiagnostics(opts, bufnr, line_nr, client_id) +-- bufnr = bufnr or 0 +-- line_nr = line_nr or (vim.api.nvim_win_get_cursor(0)[1] - 1) +-- opts = opts or { ['lnum'] = line_nr } +-- +-- local line_diagnostics = vim.diagnostic.get(bufnr, opts) +-- if vim.tbl_isempty(line_diagnostics) then return end +-- +-- local diagnostic_message = "" +-- for i, diagnostic in ipairs(line_diagnostics) do +-- diagnostic_message = diagnostic_message .. string.format("%d: %s", i, diagnostic.message or "") +-- print(diagnostic_message) +-- if i ~= #line_diagnostics then +-- diagnostic_message = diagnostic_message .. "\n" +-- end +-- end +-- vim.api.nvim_echo({ { diagnostic_message, "Normal" } }, false, {}) +-- end +-- +-- vim.cmd [[ autocmd! CursorHold * lua PrintDiagnostics() ]] + +-- vim: ts=2 sts=2 sw=2 et diff --git a/init.lua b/init.lua index 72890326..6263a948 100644 --- a/init.lua +++ b/init.lua @@ -35,7 +35,6 @@ I hope you enjoy your Neovim journey, P.S. You can delete this when you're done too. It's your config now :) --]] - -- Set as the leader key -- See `:help mapleader` -- NOTE: Must happen before plugins are required (otherwise wrong leader will be used) @@ -75,7 +74,8 @@ require('lazy').setup({ -- NOTE: This is where your plugins related to LSP can be installed. -- The configuration is done below. Search for lspconfig to find it below. - { -- LSP Configuration & Plugins + { + -- LSP Configuration & Plugins 'neovim/nvim-lspconfig', dependencies = { -- Automatically install LSPs to stdpath for neovim @@ -91,14 +91,16 @@ require('lazy').setup({ }, }, - { -- Autocompletion + { + -- Autocompletion 'hrsh7th/nvim-cmp', dependencies = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip' }, }, -- Useful plugin to show you pending keybinds. - { 'folke/which-key.nvim', opts = {} }, - { -- Adds git releated signs to the gutter, as well as utilities for managing changes + { 'folke/which-key.nvim', opts = {} }, + { + -- Adds git releated signs to the gutter, as well as utilities for managing changes 'lewis6991/gitsigns.nvim', opts = { -- See `:help gitsigns.txt` @@ -112,28 +114,22 @@ require('lazy').setup({ }, }, - { -- Theme inspired by Atom - 'navarasu/onedark.nvim', - priority = 1000, - config = function() - vim.cmd.colorscheme 'onedark' - end, - }, - - { -- Set lualine as statusline + { + -- Set lualine as statusline 'nvim-lualine/lualine.nvim', -- See `:help lualine.txt` opts = { options = { icons_enabled = false, - theme = 'onedark', + theme = 'base16', component_separators = '|', section_separators = '', }, }, }, - { -- Add indentation guides even on blank lines + { + -- Add indentation guides even on blank lines 'lukas-reineke/indent-blankline.nvim', -- Enable `lukas-reineke/indent-blankline.nvim` -- See `:help indent_blankline.txt` @@ -144,7 +140,7 @@ require('lazy').setup({ }, -- "gc" to comment visual regions/lines - { 'numToStr/Comment.nvim', opts = {} }, + { 'numToStr/Comment.nvim', opts = {} }, -- Fuzzy Finder (files, lsp, etc) { 'nvim-telescope/telescope.nvim', version = '*', dependencies = { 'nvim-lua/plenary.nvim' } }, @@ -162,7 +158,8 @@ require('lazy').setup({ end, }, - { -- Highlight, edit, and navigate code + { + -- Highlight, edit, and navigate code 'nvim-treesitter/nvim-treesitter', dependencies = { 'nvim-treesitter/nvim-treesitter-textobjects', @@ -175,7 +172,7 @@ 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.autoformat', -- require 'kickstart.plugins.debug', -- NOTE: The import below automatically adds your own plugins, configuration, etc from `lua/custom/plugins/*.lua` @@ -291,7 +288,7 @@ require('nvim-treesitter.configs').setup { ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'typescript', 'help', 'vim' }, -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) - auto_install = false, + auto_install = true, highlight = { enable = true }, indent = { enable = true, disable = { 'python' } }, @@ -385,7 +382,7 @@ local on_attach = function(_, bufnr) -- 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') @@ -407,12 +404,14 @@ end -- Add any additional override configuration in the following tables. They will be passed to -- the `settings` field of the server config. You must look up that documentation yourself. local servers = { - -- clangd = {}, - -- gopls = {}, - -- pyright = {}, - -- rust_analyzer = {}, - -- tsserver = {}, - + clangd = {}, + cssls = {}, + eslint = {}, + gopls = {}, + pyright = {}, + rust_analyzer = {}, + stylelint_lsp = {}, + tsserver = {}, lua_ls = { Lua = { workspace = { checkThirdParty = false }, diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index be0eb9d8..98029f39 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -1,5 +1,26 @@ --- 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 { + { "github/copilot.vim", }, + { "myusuf3/numbers.vim", }, + { "tpope/vim-eunuch", }, + { "tpope/vim-repeat", }, + { "tpope/vim-surround" }, + + { + "nvim-tree/nvim-web-devicons", + opts = {} + }, + + { + "windwp/nvim-autopairs", + config = function() + require("nvim-autopairs").setup {} + end, + }, + + { + "kristijanhusak/vim-dirvish-git", + dependencies = { + "justinmk/vim-dirvish", + }, + }, +} diff --git a/lua/custom/plugins/nvim-base16.lua b/lua/custom/plugins/nvim-base16.lua new file mode 100644 index 00000000..6e8be747 --- /dev/null +++ b/lua/custom/plugins/nvim-base16.lua @@ -0,0 +1,10 @@ +return { + 'norcalli/nvim-base16.lua', + lazy = false, + priority = 1000, + config = function() + local base16 = require 'base16' + + base16(base16.themes[vim.env.BASE16_THEME or "3024"], true) + end, +} diff --git a/lua/custom/plugins/reveal.lua b/lua/custom/plugins/reveal.lua new file mode 100644 index 00000000..95a67294 --- /dev/null +++ b/lua/custom/plugins/reveal.lua @@ -0,0 +1,20 @@ +-- RevealInFinder +-- --------------------------------------------------------------------------- + +-- set this to leader-e +vim.cmd([[ +function! s:RevealInFinder() + if filereadable(expand("%")) + let l:command = "open -R %" + elseif getftype(expand("%:p:h")) == "dir" + let l:command = "open %:p:h" + else + let l:command = "open ." + endif + execute ":silent! !" . l:command + redraw! +endfunction +command! Reveal call RevealInFinder() +]]) + +return {} diff --git a/lua/kickstart/plugins/autoformat.lua b/lua/kickstart/plugins/autoformat.lua index bc56b15b..1bbd622e 100644 --- a/lua/kickstart/plugins/autoformat.lua +++ b/lua/kickstart/plugins/autoformat.lua @@ -46,9 +46,9 @@ return { -- Tsserver usually works poorly. Sorry you work with bad languages -- You can remove this line if you know what you're doing :) - if client.name == 'tsserver' then - return - end + -- if client.name == 'tsserver' then + -- return + -- end -- Create an autocmd that will run *before* we save the buffer. -- Run the formatting command for the LSP that has just attached.