Update nvim config.

This commit is contained in:
Devin Lumley 2022-11-22 18:25:35 -08:00
parent d65a5daf96
commit 83a6862734
8 changed files with 171 additions and 11 deletions

View file

@ -65,3 +65,7 @@ vim.opt.ignorecase = true -- case insensitive search...
vim.opt.smartcase = true -- unless I use caps vim.opt.smartcase = true -- unless I use caps
vim.opt.hlsearch = true -- highlight matching text vim.opt.hlsearch = true -- highlight matching text
vim.opt.incsearch = true -- update results while I type vim.opt.incsearch = true -- update results while I type
-- Better Netrw
vim.g.netrw_banner = 0 -- Hide banner
vim.g.netrw_list_hide = (vim.fn["netrw_gitignore#Hide"]()) .. [[,\(^\|\s\s\)\zs\.\S\+]] -- use .gitignore

View file

@ -12,6 +12,8 @@ local lsp_filetypes = {
-- "lua", -- "lua",
} }
local signs = { Error = "", Warn = "", Hint = "", Info = "" }
-- Give floating windows borders -- Give floating windows borders
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" }) vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" })
@ -23,7 +25,8 @@ vim.diagnostic.config({
-- Prepend with diagnostic source if there is more than one attached to the buffer -- Prepend with diagnostic source if there is more than one attached to the buffer
-- (e.g. (eslint) Error: blah blah blah) -- (e.g. (eslint) Error: blah blah blah)
source = "if_many", source = "if_many",
signs = false, spacing = 4,
prefix = "",
}, },
float = { float = {
severity_sort = true, severity_sort = true,
@ -281,6 +284,11 @@ lspconfig.yamlls.setup({
-- on_attach = custom_attach, -- on_attach = custom_attach,
-- }) -- })
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
end
return { return {
lsp_filetypes = lsp_filetypes, lsp_filetypes = lsp_filetypes,
} }

View file

@ -11,6 +11,16 @@ mapper("n", "gd", ":vs | lua vim.lsp.buf.definition()<CR>") -- open defn in a ne
if no_plugins then return end if no_plugins then return end
-- Telescope integration
local telescope_builtin = require("telescope.builtin") local telescope_builtin = require("telescope.builtin")
mapper("n", "<C-p>", telescope_builtin.find_files) -- search all files, respecting .gitignore if one exists mapper("n", "<Leader>ff", telescope_builtin.find_files) -- search all files, respecting .gitignore if one exists
mapper("n", "<Leader>fb", telescope_builtin.buffers) -- search open buffers
mapper("n", "<Leader>fl", telescope_builtin.current_buffer_fuzzy_find) -- search lines in current buffer
mapper("n", "<Leader>gg", telescope_builtin.live_grep) -- search all lines in project
mapper("n", "<Leader>fr", telescope_builtin.lsp_references) -- search references to symbol under cursor
mapper("n", "<Leader>gc", telescope_builtin.git_branches) -- checkout different branches
-- Git things
mapper("n", "<Leader>gs", ":vs Git<CR>") -- `git status` in a new tab to save screen real estate
mapper("n", "<Leader>gd", "<cmd>Gdiffsplit<CR>") -- open a split diffing the current file

View file

@ -3,6 +3,7 @@ local cmp_autopairs = require('nvim-autopairs.completion.cmp')
if not cmp then return end if not cmp then return end
cmp.setup({ cmp.setup({
preselect = true,
snippet = { snippet = {
expand = function(args) vim.fn["vsnip#anonymous"](args.body) end, expand = function(args) vim.fn["vsnip#anonymous"](args.body) end,
}, },
@ -18,13 +19,13 @@ cmp.setup({
["<C-f>"] = cmp.mapping.scroll_docs(-4), ["<C-f>"] = cmp.mapping.scroll_docs(-4),
["<C-d>"] = cmp.mapping.scroll_docs(4), ["<C-d>"] = cmp.mapping.scroll_docs(4),
["<C-h>"] = cmp.mapping.complete({ reason = cmp.ContextReason.Manual }), ["<C-h>"] = cmp.mapping.complete({ reason = cmp.ContextReason.Manual }),
["<C-e>"] = cmp.mapping.close(), ["<Esc>"] = cmp.mapping.close(),
["<C-y>"] = cmp.mapping.confirm({ ["<CR>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert, behavior = cmp.ConfirmBehavior.Insert,
select = true, -- use first result if none explicitly selected select = true, -- use first result if none explicitly selected
}), }),
-- ["<C-n>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), ["<Tab>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }),
-- ["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), ["<S-Tab>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }),
}), }),
preselect = cmp.PreselectMode.None, preselect = cmp.PreselectMode.None,
formatting = { formatting = {

View file

@ -0,0 +1,98 @@
local lualine = require("lualine")
local IS_WIDE = function() return vim.o.columns > 150 end
lualine.setup({
sections = {
--+-------------------------------------------------+--
--| A | B | C X | Y | Z |--
--+-------------------------------------------------+--
lualine_a = {
{
"mode",
fmt = function(m) return IS_WIDE() and m or m:sub(1, 1) end,
},
},
lualine_b = { "branch" },
lualine_c = {
{
"diff",
symbols = {
modified = "~",
removed = "-",
added = "+",
},
},
-- A hack to change the path type if the window gets too short. Lualine doesn't accept a function for the
-- `path` option, so just swap out the entire component
{
"filename",
path = 1, -- full file path
color = { fg = "#ffffff", gui = "bold" },
shorting_target = 30,
cond = IS_WIDE,
},
{
"filename",
path = 0, -- just the filename
color = { fg = "#ffffff", gui = "bold" },
shorting_target = 30,
cond = function() return not IS_WIDE() end,
},
},
lualine_x = {
{
function()
local msg = "No Active Lsp"
local buf_ft = vim.api.nvim_buf_get_option(0, "filetype")
local clients = vim.lsp.get_active_clients()
if next(clients) == nil then return msg end
local client_names = {}
local active_client = false
for _, client in ipairs(clients) do
local filetypes = client.config.filetypes
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
active_client = true
if not client_names[client.name] then client_names[client.name] = 1 end
end
end
if active_client then
local names = {}
for name, _ in pairs(client_names) do
table.insert(names, name)
end
return table.concat(names, ", ")
end
return "No Active Lsp"
end,
icon = " LSP:",
color = { gui = "bold" },
cond = IS_WIDE,
},
{
"diagnostics",
sources = { "nvim_diagnostic" },
},
},
lualine_y = { "filetype" },
lualine_z = { "location" },
},
tabline = {},
options = {
section_separators = { left = "", right = "" },
component_separators = { left = "", right = "" },
theme = "tokyonight",
disabled_filetypes = { "aerial" },
globalstatus = true,
},
extensions = {
"aerial",
"fugitive",
"nvim-dap-ui",
"nvim-tree",
"quickfix",
},
})

View file

@ -0,0 +1,21 @@
local telescope = require("telescope")
telescope.setup({
defaults = {
file_ignore_patterns = {
"%.png",
"^index.%",
},
prompt_prefix = "» ",
selection_caret = "",
selection_strategy = "reset",
sorting_strategy = "ascending",
layout_strategy = "horizontal",
path_display = { "smart" },
dynamic_preview_title = true,
layout_config = {
prompt_position = "top",
height = 0.8,
},
},
})

View file

@ -23,7 +23,7 @@ packer.startup(function(use)
-- Essentials -- Essentials
use({ use({
"nvim-telescope/telescope.nvim", -- fuzzy find ALL the things "nvim-telescope/telescope.nvim", -- fuzzy find ALL the things
-- config = function() require("dwl.plugin-conf.telescope") end, config = function() require("dwl.plugin-conf.telescope") end,
}) })
use({ use({
"windwp/nvim-ts-autotag", -- auto close html tags "windwp/nvim-ts-autotag", -- auto close html tags
@ -47,6 +47,24 @@ packer.startup(function(use)
}) })
use("lukas-reineke/indent-blankline.nvim") use("lukas-reineke/indent-blankline.nvim")
-- Look and feel
use({
"nvim-lualine/lualine.nvim", -- statusline in lua
requires = {
"kyazdani42/nvim-web-devicons",
opt = true,
},
config = function() require("dwl.plugin-conf.lualine") end,
})
-- use({
-- "nvim-tree/nvim-web-devicons",
-- config = function() require('nvim-web-devicons').setup() end,
-- })
use({
"petertriho/nvim-scrollbar",
config = function() require("scrollbar").setup() end,
})
-- LSP & Treesitter -- LSP & Treesitter
use("neovim/nvim-lspconfig") -- basic configurations for LSP client use("neovim/nvim-lspconfig") -- basic configurations for LSP client
use("jose-elias-alvarez/null-ls.nvim") -- bridge between LSP client and external formatters/linters, not full fledged language servers use("jose-elias-alvarez/null-ls.nvim") -- bridge between LSP client and external formatters/linters, not full fledged language servers