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

@ -1,4 +1 @@
require('settings') require('core.init')
require('plugins')
require('mappings')
require('autocmd')

View file

@ -0,0 +1,28 @@
{
"bufferline.nvim": { "branch": "main", "commit": "243893ba9d5d1049dd451a25cab32ec7f8f67bcf" },
"fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" },
"gitsigns.nvim": { "branch": "main", "commit": "a36bc3360d584d39b4fb076d855c4180842d4444" },
"gruvbox.nvim": { "branch": "main", "commit": "df149bccb19a02c5c2b9fa6ec0716f0c0487feb0" },
"hop.nvim": { "branch": "master", "commit": "03f0434869f1f38868618198b5f4f2ab6d39aef2" },
"indent-blankline.nvim": { "branch": "master", "commit": "7075d7861f7a6bbf0de0298c83f8a13195e6ec01" },
"lazy.nvim": { "branch": "main", "commit": "c1aad95243f0d180f41348be26b2417547fb168b" },
"lualine.nvim": { "branch": "master", "commit": "05d78e9fd0cdfb4545974a5aa14b1be95a86e9c9" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "d381fcb78d7a562c3244e1c8f76406954649db36" },
"mason.nvim": { "branch": "main", "commit": "f7f81ab41b153e2902ebded401a8a0a6abe28607" },
"mini.nvim": { "branch": "main", "commit": "3a11a130bac227462dd226669d260c4bbe33fb5b" },
"neodev.nvim": { "branch": "main", "commit": "78f1c370173e7689bd58d64229b4d92c5dfb2793" },
"null-ls.nvim": { "branch": "main", "commit": "bbaf5a96913aa92281f154b08732be2f57021c45" },
"nvim-lsp-basics": { "branch": "main", "commit": "632714bd3ab355eb6e725b5a78cd8730f12d14d2" },
"nvim-lspconfig": { "branch": "master", "commit": "a51892484c2002c083a8b0a9dfcefb3a569be36d" },
"nvim-treesitter": { "branch": "master", "commit": "1897926700b6b0add1cf25c8ff0ba5f6e917814e" },
"nvim-web-devicons": { "branch": "master", "commit": "14b3a5ba63b82b60cde98d0a40319d80f25e8301" },
"plenary.nvim": { "branch": "master", "commit": "36aaceb6e93addd20b1b18f94d86aecc552f30c4" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "9bc8237565ded606e6c366a71c64c0af25cd7a50" },
"telescope.nvim": { "branch": "0.1.x", "commit": "776b509f80dd49d8205b9b0d94485568236d1192" },
"trouble.nvim": { "branch": "main", "commit": "2af0dd9767526410c88c628f1cbfcb6cf22dd683" },
"vim-fugitive": { "branch": "master", "commit": "43f18ab9155c853a84ded560c6104e6300ad41da" },
"vim-illuminate": { "branch": "master", "commit": "a2907275a6899c570d16e95b9db5fd921c167502" },
"vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" },
"vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" },
"which-key.nvim": { "branch": "main", "commit": "d871f2b664afd5aed3dc1d1573bef2fb24ce0484" }
}

View file

@ -1,7 +0,0 @@
local api = vim.api
-- set the theme to gruvbox
api.nvim_command("autocmd vimenter * ++nested colorscheme gruvbox")
-- run nvim-lightbulb for all files
vim.cmd [[autocmd CursorHold,CursorHoldI * lua require'nvim-lightbulb'.update_lightbulb()]]

View file

@ -0,0 +1,2 @@
local colorscheme = require("helpers.colorscheme")
vim.cmd.colorscheme(colorscheme)

View file

@ -0,0 +1,3 @@
require("core.options")
require("core.lazy")
require("core.colorscheme")

View file

@ -0,0 +1,32 @@
-- Install lazy.nvim if not already installed
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
-- Use a protected call so we don't error out on first use
local ok, lazy = pcall(require, "lazy")
if not ok then
return
end
local keys = require("helpers.keys")
-- We have to set the leader key here for lazy.nvim to work
keys.set_leader("\\")
-- Load plugins from specifications
-- (The leader key must be set before this)
lazy.setup("plugins")
-- Might as well set up an easy-access keybinding
keys.map("n", "<leader>L", lazy.show, "Show Lazy")

View file

@ -0,0 +1,23 @@
local opts = {
termguicolors = true, -- enable 24 bit colors
-- tabs look like 4 spaces {
expandtab = true,
tabstop = 4,
shiftwidth = 4,
softtabstop = 4,
-- }
number = true, -- show line numbers
mouse = 'c', -- disable mouse
laststatus = 2, -- always show the status line
autoindent = true, -- turn on autoindent
smarttab = true, -- turn on smart tabs
incsearch = true, -- turn on incremental search
ruler = true, -- show ruler on page
lazyredraw = true, -- make large file bearable
regexpengine = 1, -- make searching large files bearable
background = 'dark' -- use dark theme
}
for opt, val in pairs(opts) do
vim.o[opt] = val
end

View file

@ -0,0 +1,29 @@
{
"workspace.library": [
"/Users/tony.blyler/.local/share/nvim/lazy/neodev.nvim/types/stable",
"/opt/homebrew/Cellar/neovim/0.9.1/share/nvim/runtime/lua",
"/Users/tony.blyler/.local/share/nvim/lazy/bufferline.nvim/lua",
"/Users/tony.blyler/.local/share/nvim/lazy/fidget.nvim/lua",
"/Users/tony.blyler/.local/share/nvim/lazy/nvim-web-devicons/lua",
"/Users/tony.blyler/.local/share/nvim/lazy/lualine.nvim/lua",
"/Users/tony.blyler/.local/share/nvim/lazy/hop.nvim/lua",
"/Users/tony.blyler/.local/share/nvim/lazy/vim-illuminate/lua",
"/Users/tony.blyler/.local/share/nvim/lazy/lazy.nvim/lua",
"/Users/tony.blyler/.local/share/nvim/lazy/nvim-lspconfig/lua",
"/Users/tony.blyler/.local/share/nvim/lazy/gruvbox.nvim/lua",
"/Users/tony.blyler/.local/share/nvim/lazy/plenary.nvim/lua",
"/Users/tony.blyler/.local/share/nvim/lazy/cmp-nvim-lsp/lua",
"/Users/tony.blyler/.local/share/nvim/lazy/which-key.nvim/lua",
"/Users/tony.blyler/.local/share/nvim/lazy/trouble.nvim/lua",
"/Users/tony.blyler/.local/share/nvim/lazy/mason.nvim/lua",
"/Users/tony.blyler/.local/share/nvim/lazy/telescope-fzf-native.nvim/lua",
"/Users/tony.blyler/.local/share/nvim/lazy/nvim-treesitter/lua",
"/Users/tony.blyler/.local/share/nvim/lazy/telescope.nvim/lua",
"/Users/tony.blyler/.local/share/nvim/lazy/neodev.nvim/lua",
"/Users/tony.blyler/.local/share/nvim/lazy/mason-lspconfig.nvim/lua",
"/Users/tony.blyler/.local/share/nvim/lazy/mini.nvim/lua",
"/Users/tony.blyler/.local/share/nvim/lazy/gitsigns.nvim/lua",
"/Users/tony.blyler/.config/nvim/lua",
"${3rd}/luv/library"
]
}

View file

@ -0,0 +1,20 @@
-- Fetch and setup colorscheme if available, otherwise just return 'default'
-- This should prevent Neovim from complaining about missing colorschemes on first boot
local function get_if_available(name, opts)
local lua_ok, colorscheme = pcall(require, name)
if lua_ok then
colorscheme.setup(opts)
return name
end
local vim_ok, _ = pcall(vim.cmd.colorscheme, name)
if vim_ok then
return name
end
return "default"
end
local colorscheme = get_if_available('gruvbox')
return colorscheme

View file

@ -0,0 +1,21 @@
local M = {}
M.map = function(mode, lhs, rhs, desc)
vim.keymap.set(mode, lhs, rhs, { silent = true, desc = desc })
end
M.lsp_map = function(lhs, rhs, bufnr, desc)
vim.keymap.set("n", lhs, rhs, { silent = true, buffer = bufnr, desc = desc })
end
M.dap_map = function(mode, lhs, rhs, desc)
M.map(mode, lhs, rhs, desc)
end
M.set_leader = function(key)
vim.g.mapleader = key
vim.g.maplocalleader = key
M.map({ "n", "v" }, key, "<nop>")
end
return M

View file

@ -1,26 +0,0 @@
local api = vim.api
local M = {}
function M.map(mode, keydef, command, opts)
local options = {noremap = true}
if opts then options = vim.tbl_extend("force", options, opts) end
api.nvim_set_keymap(mode, keydef, command, options)
end
-- fzf searching
M.map("", "<leader>ff", "<cmd>lua require('telescope.builtin').find_files()<cr>")
M.map("", "<leader>fg", "<cmd>lua require('telescope.builtin').live_grep()<cr>")
M.map("", "<leader>fb", "<cmd>lua require('telescope.builtin').buffers()<cr>")
M.map("", "<leader>fh", "<cmd>lua require('telescope.builtin').help_tags()<cr>")
M.map("", "<leader>fb", "<cmd>lua require('telescope.builtin').file_browser()<cr>")
-- easymotion
M.map("", "<leader><leader>j", "<cmd>lua require('hop').hint_lines({direction = require('hop.hint').HintDirection.AFTER_CURSOR})<cr>")
M.map("", "<leader><leader>k", "<cmd>lua require('hop').hint_lines({direction = require('hop.hint').HintDirection.BEFORE_CURSOR})<cr>")
M.map("", "<leader><leader>l", "<cmd>lua require('hop').hint_words({direction = require('hop.hint').HintDirection.AFTER_CURSOR, current_line_only = true})<cr>")
M.map("", "<leader><leader>h", "<cmd>lua require('hop').hint_words({direction = require('hop.hint').HintDirection.BEFORE_CURSOR, current_line_only = true})<cr>")
api.nvim_command(":command Bd lua MiniBufremove.delete()")
api.nvim_command(":command FixWhitespace lua MiniTrailspace.trim()")
return M

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
}
}
}

View file

@ -1,28 +0,0 @@
local g = vim.g
local opt = vim.opt
local cmd = vim.cmd
-- color theme
-- gruvbox is used via the autocmd require
g.gruvbox_contrast_dark = "hard" -- hard contrast mode for gruvobx
opt.background = "dark" -- make sure dark mode is used
opt.termguicolors = true -- enable 24 bit colors
opt.mouse = 'c' -- disable mouse
opt.number = true -- show line numbers
-- opt.cursorline = true -- highlight the line that the cursor is on
opt.laststatus = 2 -- always show the status line
opt.autoindent = true -- turn on autoindent
opt.smarttab = true -- turn on smart tabs
opt.incsearch = true -- turn on incremental search
opt.ruler = true -- show ruler on page
opt.lazyredraw = true -- make large files bearable
opt.regexpengine = 1 -- make searching large files bearable
-- tabs look like 4 spaces
opt.expandtab = true
opt.tabstop = 4
opt.shiftwidth = 4
opt.softtabstop = 4
cmd('filetype plugin indent on')