diff --git a/doc/dependencies.txt b/doc/dependencies.txt new file mode 100644 index 00000000000..b23be28c47a --- /dev/null +++ b/doc/dependencies.txt @@ -0,0 +1 @@ +`brew install ripgrep` diff --git a/init.lua b/init.lua index 220d3045268..670dbdcebf9 100644 --- a/init.lua +++ b/init.lua @@ -91,7 +91,7 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = false +vim.g.have_nerd_font = true -- [[ Setting options ]] -- See `:help vim.opt` @@ -228,6 +228,9 @@ vim.opt.rtp:prepend(lazypath) -- -- NOTE: Here is where you install your plugins. require('lazy').setup({ + -- For autosave functionality + 'pocco81/auto-save.nvim', + -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically @@ -347,12 +350,21 @@ require('lazy').setup({ -- You can put your default mappings / updates / etc. in here -- All the info you're looking for is in `:help telescope.setup()` -- - -- defaults = { - -- mappings = { - -- i = { [''] = 'to_fuzzy_refine' }, - -- }, - -- }, - -- pickers = {} + defaults = { + layout_config = { + vertical = { height = 0.9 }, + }, + }, + pickers = { + lsp_references = { theme = 'dropdown', layout_config = { width = 0.98, height = 0.4 }, previewer = true }, + diagnostics = { + theme = 'dropdown', + previewer = false, + layout_config = { + width = 0.9, + }, + }, + }, extensions = { ['ui-select'] = { require('telescope.themes').get_dropdown(), @@ -372,11 +384,16 @@ require('lazy').setup({ vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) - vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) + vim.keymap.set('n', 'sd', function() + builtin.diagnostics { + bufnr = 0, + } + end, { desc = '[S]earch [D]iagnostics' }) + -- Slightly advanced example of overriding default behavior and theme vim.keymap.set('n', '/', function() -- You can pass additional configuration to Telescope to change the theme, layout, etc. @@ -511,6 +528,29 @@ require('lazy').setup({ -- For example, in C this would take you to the header. map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + vim.api.nvim_create_autocmd('BufWritePre', { + pattern = '*.go', + callback = function() + local params = vim.lsp.util.make_range_params() + params.context = { only = { 'source.organizeImports' } } + -- buf_request_sync defaults to a 1000ms timeout. Depending on your + -- machine and codebase, you may want longer. Add an additional + -- argument after params if you find that you have to write the file + -- twice for changes to be saved. + -- E.g., vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, 3000) + local result = vim.lsp.buf_request_sync(0, 'textDocument/codeAction', params) + for cid, res in pairs(result or {}) do + for _, r in pairs(res.result or {}) do + if r.edit then + local enc = (vim.lsp.get_client_by_id(cid) or {}).offset_encoding or 'utf-16' + vim.lsp.util.apply_workspace_edit(r.edit, enc) + end + end + end + vim.lsp.buf.format { async = false } + end, + }) + -- The following two autocommands are used to highlight references of the -- word under your cursor when your cursor rests there for a little while. -- See `:help CursorHold` for information about when this is executed @@ -569,8 +609,18 @@ require('lazy').setup({ -- - settings (table): Override the default settings passed when initializing the server. -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { + ruby_lsp = {}, -- clangd = {}, - -- gopls = {}, + gopls = { + settings = { + gopls = { + analyses = { + unusedparams = true, + }, + staticcheck = true, + }, + }, + }, -- pyright = {}, -- rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs @@ -629,6 +679,45 @@ require('lazy').setup({ end, }, + { 'nvim-neotest/nvim-nio' }, + + { + 'nvim-neotest/neotest', + dependencies = { + 'nvim-treesitter/nvim-treesitter', + 'nvim-neotest/neotest-go', + }, + opts = {}, + config = function() + local neotest = require 'neotest' + + neotest.setup { + adapters = { + -- require 'neotest-rspec' { + -- rspec_cmd = function() + -- return vim.tbl_flatten { + -- 'bundle', + -- 'exec', + -- 'rspec', + -- } + -- end, + -- }, + require 'neotest-go', + }, + output_panel = { + enabled = true, + open = 'botright split | resize 15', + }, + quickfix = { + open = false, + }, + } + + vim.keymap.set('n', 'rt', 'lua require(\'neotest\').run.run(vim.fn.expand("%"))', { desc = 'Run Test' }) + vim.keymap.set('n', 'rot', 'lua require("neotest").output.open({ enter = true })', { desc = 'Open Test Output' }) + end, + }, + { -- Autoformat 'stevearc/conform.nvim', event = { 'BufWritePre' }, @@ -657,6 +746,7 @@ require('lazy').setup({ end, formatters_by_ft = { lua = { 'stylua' }, + go = { 'gofmt' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- @@ -782,21 +872,58 @@ require('lazy').setup({ end, }, - { -- You can easily change to a different colorscheme. - -- Change the name of the colorscheme plugin below, and then - -- change the command in the config to whatever the name of that colorscheme is. - -- - -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. - 'folke/tokyonight.nvim', - priority = 1000, -- Make sure to load this before all the other start plugins. + -- { -- You can easily change to a different colorscheme. + -- -- Change the name of the colorscheme plugin below, and then + -- -- change the command in the config to whatever the name of that colorscheme is. + -- -- + -- -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. + -- 'folke/tokyonight.nvim', + -- priority = 1000, -- Make sure to load this before all the other start plugins. + -- init = function() + -- -- Load the colorscheme here. + -- -- Like many other themes, this one has different styles, and you could load + -- -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. + -- vim.cmd.colorscheme 'tokyonight-moon' + -- + -- -- You can configure highlights by doing something like: + -- vim.cmd.hi 'Comment gui=none' + -- end, + -- }, + + -- { + -- 'morhetz/gruvbox', + -- priority = 1000, + -- init = function() + -- vim.g.gruvbox_contrast_dark = 'hard' + -- vim.g.gruvbox_bold = 0 + -- vim.cmd.colorscheme 'gruvbox' + -- end, + -- }, + + { + 'sainnhe/everforest', + priority = 1000, init = function() - -- Load the colorscheme here. - -- Like many other themes, this one has different styles, and you could load - -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. - vim.cmd.colorscheme 'tokyonight-night' + vim.g.everforest_enable_italic = true + vim.g.everforest_background = 'hard' + vim.cmd.colorscheme 'everforest' + end, + }, + + -- { + -- 'sainnhe/gruvbox-material', + -- priority = 1000, + -- init = function() + -- vim.g.gruvbox_material_enable_italic = true + -- vim.g.gruvbox_material_background = 'hard' + -- vim.cmd.colorscheme 'gruvbox-material' + -- end, + -- }, - -- You can configure highlights by doing something like: - vim.cmd.hi 'Comment gui=none' + { + 'vim-airline/vim-airline', + init = function() + vim.g.airline_theme = 'everforest' end, }, @@ -892,7 +1019,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' }, }, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index be0eb9d8d7a..8163e16c50c 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -2,4 +2,6 @@ -- I promise not to create any merge conflicts in this directory :) -- -- See the kickstart.nvim README for more information -return {} +return { + { dir = '~/.config/nvim/lua/custom/toms.nvim/' }, +} diff --git a/lua/custom/toms.nvim/lua/toms.lua b/lua/custom/toms.nvim/lua/toms.lua new file mode 100644 index 00000000000..1d15dd42e98 --- /dev/null +++ b/lua/custom/toms.nvim/lua/toms.lua @@ -0,0 +1,10 @@ +print 'loaded tom.lua' + +function List_bufs() + vim.print(vim.api.nvim_list_bufs()) +end + +-- function ListDiag() +-- +-- vim.print(vim. +-- end diff --git a/lua/custom/toms.nvim/plugin/load.lua b/lua/custom/toms.nvim/plugin/load.lua new file mode 100644 index 00000000000..28e054582d0 --- /dev/null +++ b/lua/custom/toms.nvim/plugin/load.lua @@ -0,0 +1 @@ +require 'toms'