Update neovim config to be a bit more sane

This commit is contained in:
Tony Blyler 2023-06-20 17:13:50 -04:00
parent 673ef32dd0
commit 559a0b453e
39 changed files with 510 additions and 373 deletions

View file

@ -0,0 +1,9 @@
-- See current buffers at the top of the editor
return {
{
"akinsho/bufferline.nvim",
version = "v3.*",
dependencies = "nvim-tree/nvim-web-devicons",
opts = {},
},
}

View file

@ -1 +0,0 @@
require("bufferline").setup()

View file

@ -1,46 +0,0 @@
local cmp = require'cmp'
cmp.setup({
snippet = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
end,
},
mapping = {
['<tab>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
['<C-p>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
['<Down>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }),
['<Up>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true,
})
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' }, -- For luasnip users.
}, {
{ name = 'buffer' },
})
})
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline('/', {
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})

View file

@ -1,7 +0,0 @@
require("gitsigns").setup {
current_line_blame = true,
current_line_blame_opts = {
virt_text = true,
delay = 0,
},
}

View file

@ -1 +0,0 @@
require("hop").setup()

View file

@ -1,6 +0,0 @@
require("indent_blankline").setup {
show_current_context = true,
show_current_context_start = true,
}
vim.g.indent_blankline_use_treesitter = true

View file

@ -1,10 +0,0 @@
local lightbulb = require("nvim-lightbulb")
lightbulb.get_status_text()
lightbulb.update_lightbulb({
status_text = {
enabled = true,
text = "💡",
text_unavailble = "",
}
})

View file

@ -1,112 +0,0 @@
require("nvim-lsp-installer").setup({
automatic_installation = true,
})
local lsp_installer_servers = require'nvim-lsp-installer.servers'
local cmp_lsp = require('cmp_nvim_lsp')
local null_ls = require("null-ls")
local lspconfig = require("lspconfig")
null_ls.setup({
sources = {
null_ls.builtins.diagnostics.vale,
},
})
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
-- Enable completion triggered by <c-x><c-o>
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
local opts = { noremap=true, silent=true }
-- See `:help vim.lsp.*` for documentation on any of the below functions
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
--buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
buf_set_keymap('n', 'gd', "<cmd>lua require('telescope.builtin').lsp_definitions()<CR>", opts)
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
--buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
buf_set_keymap('n', 'gi', "<cmd>lua require('telescope.builtin').lsp_implementations()<CR>", opts)
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
--buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
buf_set_keymap('n', '<space>D', "<cmd>lua require('telescope.builtin').lsp_type_definitions()<CR>", opts)
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
--buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
buf_set_keymap('n', '<space>ca', "<cmd>lua require('telescope.builtin').lsp_code_actions()<CR>", opts)
--buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
buf_set_keymap('', 'gr', "<cmd>lua require('telescope.builtin').lsp_references()<CR>", opts)
buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
require("lsp-status").on_attach(client) -- required for LSP status to function
local basics = require("lsp_basics") -- adds nice human accessible LSP commands
basics.make_lsp_commands(client, bufnr)
basics.make_lsp_mappings(client, bufnr)
local sources = {
null_ls.builtins.formatting.gofumpt,
null_ls.builtins.formatting.goimports,
null_ls.builtins.formatting.isort,
null_ls.builtins.formatting.black.with({
extra_args = { "-l 120" }
}),
null_ls.builtins.diagnostics.flake8.with({
extra_args = { "--max-line-length=120" }
}),
null_ls.builtins.formatting.rubocop,
null_ls.builtins.formatting.rustfmt,
null_ls.builtins.diagnostics.shellcheck,
null_ls.builtins.formatting.stylua,
}
null_ls.setup({sources = sources })
end
local lspServers = {
bashls = {},
cssls = {},
dockerls = {},
eslint = {},
gopls = {
cmd = {"gopls", "serve"},
settings = {
gopls = {
analyses = {
unusedparams = true,
},
staticcheck = true,
},
},
},
html = {},
jsonls = {},
sumneko_lua = {},
jedi_language_server = {},
rust_analyzer = {},
terraformls = {},
tsserver = {},
lemminx = {},
yamlls = {}
}
for lspServer, opts in pairs(lspServers) do
local server_available, requested_server = lsp_installer_servers.get_server(lspServer)
if server_available then
opts["capabilities"] = cmp_lsp.default_capabilities(vim.lsp.protocol.make_client_capabilities())
opts["on_attach"] = on_attach
lspconfig[lspServer].setup(opts)
if not requested_server:is_installed() then
requested_server:install()
end
end
end

View file

@ -1,5 +0,0 @@
require("mini.bufremove").setup()
require("mini.comment").setup()
require("mini.cursorword").setup()
require("mini.surround").setup()
require("mini.trailspace").setup()

View file

@ -1,2 +0,0 @@
local statusline = require('statusline')
statusline.tabline = false

View file

@ -1,14 +0,0 @@
local telescope = require("telescope")
telescope.setup({
extensions = {
fzf = {
fuzzy = true,
override_generic_sorter = true,
override_file_sorter = true,
case_mode = "smart_case",
},
},
})
telescope.load_extension("fzf")

View file

@ -1,28 +0,0 @@
require'nvim-treesitter.configs'.setup {
ensure_installed = "all", -- one of "all", "maintained" (parsers with maintainers), or a list of languages
sync_install = false, -- install languages synchronously (only applied to `ensure_installed`)
ignore_install = {"phpdoc", "tree-sitter-phpdoc"}, -- List of parsers to ignore installing
autopairs = {
enable = true,
},
highlight = {
enable = true, -- false will disable the whole extension
disable = {"phpdoc", "tree-sitter-phpdoc"}, -- list of language that will be disabled
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false,
},
rainbow = {
enable = true,
extended_mode = true,
},
indent = {
enable = true,
},
context_commentstring = {
enable = true,
enable_autocmd = true,
},
}

View file

@ -1,4 +0,0 @@
require("trouble").setup({
-- configuration here
-- or leave it empty to use the default settings
})

View file

@ -0,0 +1,25 @@
return {
{
"phaazon/hop.nvim",
config = function()
local hop = require("hop")
hop.setup()
local directions = require("hop.hint").HintDirection
local map = require("helpers.keys").map
map("", "<leader><leader>j", function()
hop.hint_lines({direction = directions.AFTER_CURSOR})
end)
map("", "<leader><leader>k", function()
hop.hint_lines({direction = directions.BEFORE_CURSOR})
end)
map("", "<leader><leader>l", function()
hop.hint_words({direction = directions.AFTER_CURSOR, current_line_only = true})
end)
map("", "<leader><leader>h", function()
hop.hint_words({direction = directions.BEFORE_CURSOR, current_line_only = true})
end)
end,
}
}

View file

@ -0,0 +1,21 @@
-- Git related plugins
return {
{
"lewis6991/gitsigns.nvim",
opts = {
current_line_blame = true,
current_line_blame_opts = {
virt_text = true,
delay = 0,
},
},
},
{
"tpope/vim-fugitive",
config = function ()
local map = require("helpers.keys").map
map("n", "<leader>ga", "<cmd>Git add %<cr>", "Stage the current file")
map("n", "<leader>gb", "<cmd>Git blame<cr>", "Show the blame")
end
}
}

View file

@ -0,0 +1,10 @@
return {
{
"lukas-reineke/indent-blankline.nvim",
opts = {
show_current_context = true,
show_current_context_start = true,
use_treesitter = true,
},
}
}

View file

@ -1,72 +0,0 @@
local fn = vim.fn
local install_path = fn.stdpath('data') .. '/site/pack/paqs/start/paq-nvim'
if fn.empty(fn.glob(install_path)) > 0 then
fn.system({'git', 'clone', '--depth=1', 'https://github.com/savq/paq-nvim.git', install_path})
end
require "paq" {
"savq/paq-nvim"; -- let Paq manage itself
"morhetz/gruvbox"; -- gruvbox theme
"kyazdani42/nvim-web-devicons"; -- per the name, fancy icons with a Nerd Font patched font
"lewis6991/gitsigns.nvim"; -- git gutter
"nvim-lua/plenary.nvim"; -- dependency of lewis6991/gitsigns.nvim, nvim-telescope/telescope.nvim
"nvim-telescope/telescope.nvim"; -- nice searching
{"nvim-telescope/telescope-fzf-native.nvim", run="zsh -c make"}; -- enable fzf searching for telescope
"phaazon/hop.nvim"; -- easymotion navigation
"beauwilliams/statusline.lua"; -- statusline
"akinsho/bufferline.nvim"; -- bufferline
"echasnovski/mini.nvim"; -- bunch of good small plugins: whitespace, buffer layout, commenting, surround, etc
"tpope/vim-fugitive"; -- __the__ git plugin
{"nvim-treesitter/nvim-treesitter", run=TSUpdate}; -- nice and quick syntax tree
"lukas-reineke/indent-blankline.nvim"; -- pretty visualization of line indents
"kosayoda/nvim-lightbulb"; -- shows a light bulb like vs code for code actions
"nvim-lua/lsp-status.nvim"; -- nice statusline components for LSP servers
"tpope/vim-sleuth"; -- automatic tab/spaces detection
"rhysd/vim-grammarous"; -- grammar checking
"earthly/earthly.vim"; -- Earthfile support
-- LSP Server
"neovim/nvim-lspconfig";
"williamboman/nvim-lsp-installer";
"jose-elias-alvarez/null-ls.nvim";
"nanotee/nvim-lsp-basics";
"folke/trouble.nvim";
-- autocomplete with nvim-cmp
"hrsh7th/cmp-nvim-lsp";
"hrsh7th/cmp-buffer";
"hrsh7th/cmp-path";
"hrsh7th/cmp-cmdline";
"hrsh7th/nvim-cmp";
"L3MON4D3/LuaSnip";
"saadparwaiz1/cmp_luasnip";
}
require("plugins.config.bufferline")
require("plugins.config.cmp")
require("plugins.config.gitsigns")
require("plugins.config.hop")
require("plugins.config.indentblankline")
require("plugins.config.lightbulb")
require("plugins.config.lspinstall")
require("plugins.config.mini")
require("plugins.config.statusline")
require("plugins.config.telescope")
require("plugins.config.treesitter")

View file

@ -0,0 +1,146 @@
-- LSP Configuration & Plugins
return {
{
"neovim/nvim-lspconfig",
dependencies = {
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
{
"j-hui/fidget.nvim",
tag = "legacy",
},
"folke/neodev.nvim",
"RRethy/vim-illuminate",
"nanotee/nvim-lsp-basics",
"jose-elias-alvarez/null-ls.nvim",
},
config = function()
-- Set up Mason before anything else
require("mason").setup()
require("mason-lspconfig").setup({
ensure_installed = {
"lua_ls",
},
automatic_installation = true,
})
-- Quick access via keymap
require("helpers.keys").map("n", "<leader>M", "<cmd>Mason<cr>", "Show Mason")
-- Neodev setup before LSP config
require("neodev").setup()
-- Turn on LSP status information
require("fidget").setup()
-- linter and formatter configurations
local null_ls = require("null-ls")
null_ls.setup({
sources = {
null_ls.builtins.formatting.prettier,
null_ls.builtins.formatting.gofumpt,
null_ls.builtins.formatting.goimports,
null_ls.builtins.formatting.isort,
null_ls.builtins.formatting.black.with({
extra_args = { "-l 120" }
}),
null_ls.builtins.diagnostics.flake8.with({
extra_args = { "--max-line-length=120" }
}),
null_ls.builtins.formatting.rubocop,
null_ls.builtins.formatting.rustfmt,
null_ls.builtins.diagnostics.shellcheck,
null_ls.builtins.formatting.stylua,
}
})
-- Set up cool signs for diagnostics
local signs = { Error = "", Warn = "", Hint = "", Info = "" }
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
end
-- Diagnostic config
local config = {
virtual_text = false,
signs = {
active = signs,
},
update_in_insert = true,
underline = true,
severity_sort = true,
float = {
focusable = true,
style = "minimal",
border = "rounded",
source = "always",
header = "",
prefix = "",
},
}
vim.diagnostic.config(config)
-- This function gets run when an LSP connects to a particular buffer.
local on_attach = function(client, bufnr)
local basics = require("lsp_basics")
basics.make_lsp_commands(client, bufnr)
basics.make_lsp_mappings(client, bufnr)
local lsp_map = require("helpers.keys").lsp_map
lsp_map("<leader>lr", vim.lsp.buf.rename, bufnr, "Rename symbol")
lsp_map("<leader>la", vim.lsp.buf.code_action, bufnr, "Code action")
lsp_map("<leader>ld", vim.lsp.buf.type_definition, bufnr, "Type definition")
lsp_map("<leader>ls", require("telescope.builtin").lsp_document_symbols, bufnr, "Document symbols")
lsp_map("gd", vim.lsp.buf.definition, bufnr, "Goto Definition")
lsp_map("gr", require("telescope.builtin").lsp_references, bufnr, "Goto References")
lsp_map("gI", vim.lsp.buf.implementation, bufnr, "Goto Implementation")
lsp_map("K", vim.lsp.buf.hover, bufnr, "Hover Documentation")
lsp_map("gD", vim.lsp.buf.declaration, bufnr, "Goto Declaration")
-- Create a command `:Format` local to the LSP buffer
vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_)
vim.lsp.buf.format()
end, { desc = "Format current buffer with LSP" })
lsp_map("<leader>ff", "<cmd>Format<cr>", bufnr, "Format")
-- Attach and configure vim-illuminate
require("illuminate").on_attach(client)
end
local lspconfig = require("lspconfig")
require("mason-lspconfig").setup_handlers({
function(server_name)
lspconfig[server_name].setup({
on_attach = on_attach,
})
end,
["lua_ls"] = function()
lspconfig.lua_ls.setup({
on_attach = on_attach,
-- capabilities = capabilities,
settings = {
Lua = {
completion = {
callSnippet = "Replace",
},
diagnostics = {
globals = { "vim" },
},
workspace = {
library = {
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
[vim.fn.stdpath("config") .. "/lua"] = true,
},
},
},
},
})
end
})
end,
},
}

View file

@ -0,0 +1,20 @@
return {
{
"echasnovski/mini.nvim",
config = function()
require("mini.animate").setup()
require("mini.bufremove").setup()
require("mini.comment").setup()
require("mini.completion").setup()
require("mini.cursorword").setup()
require("mini.indentscope").setup({
symbol = ""
})
require("mini.surround").setup()
require("mini.trailspace").setup()
vim.api.nvim_command(":command Bd lua MiniBufremove.delete()")
vim.api.nvim_command(":command FixWhitespace lua MiniTrailspace.trim()")
end,
}
}

View file

@ -0,0 +1,4 @@
-- tpope sleuth!
return {
"tpope/vim-sleuth", -- Detect tabstop and shiftwidth automatically
}

View file

@ -0,0 +1,16 @@
-- Fancier statusline
return {
"nvim-lualine/lualine.nvim",
config = function()
local colorscheme = require("helpers.colorscheme")
local lualine_theme = colorscheme == "default" and "auto" or colorscheme
require("lualine").setup({
options = {
icons_enabled = true,
theme = lualine_theme,
component_separators = "|",
section_separators = "",
},
})
end,
}

View file

@ -0,0 +1,4 @@
-- tpope surround!
return {
"tpope/vim-surround", -- Surround stuff with the ys-, cs-, ds- commands
}

View file

@ -0,0 +1,35 @@
-- Telescope fuzzying finding all the things
return {
{
"nvim-telescope/telescope.nvim",
branch = "0.1.x",
dependencies = {
"nvim-lua/plenary.nvim",
-- Fuzzy Finder Algorithm which requires local dependencies to be built. Only load if `make` is available
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make", cond = vim.fn.executable("make") == 1 },
},
config = function()
local telescope = require("telescope")
telescope.setup({
extensions = {
fzf = {
fuzzy = true,
override_generic_sorter = true,
override_file_sorter = true,
case_mode = "smart_case",
}
}
})
-- Enable telescope fzf native, if installed
pcall(telescope.load_extension, "fzf")
local telescope_builtin = require("telescope.builtin")
local keys = require("helpers.keys")
keys.map("", "<C-p>", telescope_builtin.find_files)
keys.map("", "<leader>ff", telescope_builtin.find_files)
keys.map("", "<leader>fg", telescope_builtin.live_grep)
keys.map("", "<leader>fb", telescope_builtin.buffers)
keys.map("", "<leader>fh", telescope_builtin.help_tags)
end,
}
}

View file

@ -0,0 +1,9 @@
return {
{
"ellisonleao/gruvbox.nvim",
priority = 1000,
opts = {
contrast = "hard"
},
}
}

View file

@ -0,0 +1,27 @@
-- Highlight, edit, and navigate code
return {
{
"nvim-treesitter/nvim-treesitter",
build = function()
pcall(require("nvim-treesitter.install").update({ with_sync = true }))
end,
config = function()
require("nvim-treesitter.configs").setup({
-- Add languages to be installed here that you want installed for treesitter
ensure_installed = { "go", "javascript", "lua", "python", "rust", "typescript", "vim" },
auto_install = true,
highlight = {
enable = true,
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false,
},
indent = { enable = true },
incremental_selection = { enable = true },
})
end,
},
}

View file

@ -0,0 +1,10 @@
return {
"folke/trouble.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
require("trouble").setup()
local keys = require("helpers.keys")
keys.map("", "<leader>xx", "<cmd>TroubleToggle<cr>")
end
}

View file

@ -0,0 +1,15 @@
return {
{
"folke/which-key.nvim",
event = "VeryLazy",
init = function()
vim.o.timeout = true
vim.o.timeoutlen = 300
end,
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
}
}