fix: plugin warnings and find config files which key binding

main
Ian Mancini 2 years ago
parent f06d9d2399
commit b01bdc6734

@ -49,23 +49,12 @@ return require("packer").startup(function()
config = [[ require('refactoring').setup({}) ]], config = [[ require('refactoring').setup({}) ]],
}) })
-- Tooling
use({
"WhoIsSethDaniel/mason-tool-installer.nvim",
{
"williamboman/mason.nvim",
config = [[ require('plugins.tooling') ]],
},
})
-- LSP -- LSP
use({ use({
"folke/lsp-colors.nvim", -- Color groups "folke/lsp-colors.nvim", -- Color groups
{ "WhoIsSethDaniel/mason-tool-installer.nvim",
-- Installer "williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim", "williamboman/mason-lspconfig.nvim",
require = "williamboman/mason.nvim",
},
"folke/neodev.nvim", -- Lua "folke/neodev.nvim", -- Lua
"jose-elias-alvarez/typescript.nvim", -- Typsecript "jose-elias-alvarez/typescript.nvim", -- Typsecript
"jose-elias-alvarez/null-ls.nvim", -- Tooling "jose-elias-alvarez/null-ls.nvim", -- Tooling

@ -1,16 +1,32 @@
local wk = require("which-key") local wk = require("which-key")
require("mason").setup()
require("mason-tool-installer").setup({
ensure_installed = {
"stylua",
"shellcheck",
"shfmt",
"editorconfig-checker",
"eslint_d",
"prettier",
"prettierd",
"flake8",
"black",
},
})
require("mason-lspconfig").setup({ require("mason-lspconfig").setup({
automatic_installation = true, automatic_installation = true,
}) })
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
border = "rounded", border = "rounded",
close_events = { "CursorMoved", "BufHidden", "InsertCharPre" }, close_events = { "CursorMoved", "BufHidden", "InsertCharPre" },
}) })
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
border = "rounded", border = "rounded",
}) })
require("aerial").setup({}) require("aerial").setup({})
@ -20,133 +36,133 @@ local capabilities = require("cmp_nvim_lsp").default_capabilities()
local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
local lsp_rename_mapping = { local lsp_rename_mapping = {
function() function()
vim.lsp.buf.rename() vim.lsp.buf.rename()
end, end,
"Rename LSP symbol", "Rename LSP symbol",
} }
local lsp_references_mapping = { local lsp_references_mapping = {
"<cmd>TroubleToggle lsp_references<CR>", "<cmd>TroubleToggle lsp_references<CR>",
"LSP references", "LSP references",
} }
local on_attach = function(client, bufnr) local on_attach = function(client, bufnr)
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
-- Normal mappings -- Normal mappings
wk.register({ wk.register({
c = { c = {
a = { "<cmd>lua vim.lsp.buf.code_action()<CR>", "Code action" }, a = { "<cmd>lua vim.lsp.buf.code_action()<CR>", "Code action" },
r = lsp_rename_mapping, r = lsp_rename_mapping,
f = { f = {
"<cmd>lua vim.lsp.buf.format()<CR>", "<cmd>lua vim.lsp.buf.format()<CR>",
"Format file", "Format file",
}, },
o = { "<cmd>AerialToggle!<CR>", "Toggle outline" }, o = { "<cmd>AerialToggle!<CR>", "Toggle outline" },
x = { "<cmd>lua vim.diagnostic.open_float({source= true})<CR>", "Show line diagnostics" }, x = { "<cmd>lua vim.diagnostic.open_float({source= true})<CR>", "Show line diagnostics" },
R = lsp_references_mapping, R = lsp_references_mapping,
t = { t = {
name = "Trouble", name = "Trouble",
t = { "<cmd>TroubleToggle<CR>", "Trouble Toggle" }, t = { "<cmd>TroubleToggle<CR>", "Trouble Toggle" },
r = lsp_references_mapping, r = lsp_references_mapping,
w = { "<cmd>TroubleToggle lsp_workspace_diagnostics<CR>", "Workspace diagnostics" }, w = { "<cmd>TroubleToggle lsp_workspace_diagnostics<CR>", "Workspace diagnostics" },
d = { "<cmd>TroubleToggle lsp_document_diagnostics<CR>", "Document diagnostics" }, d = { "<cmd>TroubleToggle lsp_document_diagnostics<CR>", "Document diagnostics" },
q = { "<cmd>TroubleToggle quickfix<CR>", "Quickfix" }, q = { "<cmd>TroubleToggle quickfix<CR>", "Quickfix" },
l = { "<cmd>TroubleToggle loclist<CR>", "Location list" }, l = { "<cmd>TroubleToggle loclist<CR>", "Location list" },
}, },
g = { g = {
name = "Go to", name = "Go to",
D = { "<cmd>lua vim.lsp.buf.declaration()<CR>", "Go to declaration" }, D = { "<cmd>lua vim.lsp.buf.declaration()<CR>", "Go to declaration" },
d = { "<cmd>lua vim.lsp.buf.definition()<CR>", "Go to definition" }, d = { "<cmd>lua vim.lsp.buf.definition()<CR>", "Go to definition" },
i = { "<cmd>lua vim.lsp.buf.implementation()<CR>", "Go to implementation" }, i = { "<cmd>lua vim.lsp.buf.implementation()<CR>", "Go to implementation" },
t = { "<cmd>lua vim.lsp.buf.type_definition()<CR>", "Go to type definition" }, t = { "<cmd>lua vim.lsp.buf.type_definition()<CR>", "Go to type definition" },
}, },
}, },
}, { }, {
prefix = "<leader>", prefix = "<leader>",
buffer = bufnr, buffer = bufnr,
}) })
-- Visual mappings -- Visual mappings
wk.register({ wk.register({
c = { c = {
a = { "<cmd>lua vim.lsp.buf.code_action()<CR>", "Range code action" }, a = { "<cmd>lua vim.lsp.buf.code_action()<CR>", "Range code action" },
f = { f = {
"<cmd>lua vim.lsp.buf.format()<CR>", "<cmd>lua vim.lsp.buf.format()<CR>",
"Range formatting", "Range formatting",
}, },
}, },
}, { }, {
mode = "v", mode = "v",
prefix = "<leader>", prefix = "<leader>",
buffer = bufnr, buffer = bufnr,
}) })
-- No leader mappings -- No leader mappings
wk.register({ wk.register({
gd = { "<cmd>lua vim.lsp.buf.definition()<CR>", "Go to definition" }, gd = { "<cmd>lua vim.lsp.buf.definition()<CR>", "Go to definition" },
K = { "<cmd>lua vim.lsp.buf.hover()<CR>", "LSP Hover" }, K = { "<cmd>lua vim.lsp.buf.hover()<CR>", "LSP Hover" },
["<C-k"] = { "<cmd>lua vim.lsp.buf.signature_help()<CR>", "LSP Signature" }, ["<C-k"] = { "<cmd>lua vim.lsp.buf.signature_help()<CR>", "LSP Signature" },
["<f2>"] = lsp_rename_mapping, ["<f2>"] = lsp_rename_mapping,
["[["] = { "<cmd>AerialPrevUp<CR>", "Outline previous" }, ["[["] = { "<cmd>AerialPrevUp<CR>", "Outline previous" },
["]]"] = { "<cmd>AerialNext<CR>", "Outline next" }, ["]]"] = { "<cmd>AerialNext<CR>", "Outline next" },
}, { }, {
buffer = bufnr, buffer = bufnr,
}) })
if client.supports_method("textDocument/formatting") then if client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
vim.api.nvim_create_autocmd("BufWritePre", { vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup, group = augroup,
buffer = bufnr, buffer = bufnr,
callback = function() callback = function()
if vim.g.format_on_save == 1 then if vim.g.format_on_save == 1 then
vim.lsp.buf.format({ bufnr = bufnr }) vim.lsp.buf.format({ bufnr = bufnr })
end end
end, end,
}) })
end end
end end
local settings = { local settings = {
capabilities = capabilities, capabilities = capabilities,
on_attach = on_attach, on_attach = on_attach,
} }
-- Neovim -- Neovim
require("neodev").setup({}) require("neodev").setup({})
local servers = { local servers = {
"clangd", "clangd",
"pyright", "pyright",
"rust_analyzer", "rust_analyzer",
"gopls", "gopls",
"tailwindcss", "tailwindcss",
"jsonls", "jsonls",
"lua_ls", "lua_ls",
} }
for _, lsp in pairs(servers) do for _, lsp in pairs(servers) do
require("lspconfig")[lsp].setup(settings) require("lspconfig")[lsp].setup(settings)
end end
-- JSON -- JSON
require("lspconfig").jsonls.setup(vim.tbl_deep_extend("force", settings, { require("lspconfig").jsonls.setup(vim.tbl_deep_extend("force", settings, {
settings = { settings = {
json = { json = {
schemas = require("schemastore").json.schemas(), schemas = require("schemastore").json.schemas(),
validate = { validate = {
enable = true, enable = true,
}, },
}, },
}, },
})) }))
-- Typescript -- Typescript
require("typescript").setup({ require("typescript").setup({
disable_commands = false, disable_commands = false,
debug = false, debug = false,
server = settings, server = settings,
}) })
-- null-ls -- null-ls
@ -155,90 +171,90 @@ local null_ls = require("null-ls")
vim.g.format_on_save = 1 vim.g.format_on_save = 1
function _G.toggle_format_on_save() function _G.toggle_format_on_save()
if vim.g.format_on_save == 1 then if vim.g.format_on_save == 1 then
vim.g.format_on_save = 0 vim.g.format_on_save = 0
print("Disabled format on save") print("Disabled format on save")
else else
vim.g.format_on_save = 1 vim.g.format_on_save = 1
print("Enabled format on save") print("Enabled format on save")
end end
end end
require("null-ls").setup({ require("null-ls").setup({
timeout_ms = 5000, timeout_ms = 5000,
sources = { sources = {
-- General -- General
null_ls.builtins.code_actions.refactoring, null_ls.builtins.code_actions.refactoring,
null_ls.builtins.completion.spell, null_ls.builtins.completion.spell,
null_ls.builtins.diagnostics.trail_space, null_ls.builtins.diagnostics.trail_space,
null_ls.builtins.formatting.trim_newlines, null_ls.builtins.formatting.trim_newlines,
null_ls.builtins.formatting.trim_whitespace, null_ls.builtins.formatting.trim_whitespace,
-- Git -- Git
null_ls.builtins.code_actions.gitrebase, null_ls.builtins.code_actions.gitrebase,
null_ls.builtins.code_actions.gitsigns, null_ls.builtins.code_actions.gitsigns,
-- GitHub -- GitHub
null_ls.builtins.diagnostics.actionlint, null_ls.builtins.diagnostics.actionlint,
-- Shell -- Shell
null_ls.builtins.code_actions.shellcheck, null_ls.builtins.code_actions.shellcheck,
null_ls.builtins.diagnostics.shellcheck, null_ls.builtins.diagnostics.shellcheck,
null_ls.builtins.formatting.shfmt, null_ls.builtins.formatting.shfmt,
-- C/C++ -- C/C++
null_ls.builtins.formatting.clang_format, null_ls.builtins.formatting.clang_format,
null_ls.builtins.formatting.cmake_format, null_ls.builtins.formatting.cmake_format,
-- Web -- Web
null_ls.builtins.formatting.prettier, null_ls.builtins.formatting.prettier,
-- null_ls.builtins.code_actions.eslint_d, -- null_ls.builtins.code_actions.eslint_d,
null_ls.builtins.code_actions.eslint, null_ls.builtins.code_actions.eslint,
null_ls.builtins.diagnostics.eslint, null_ls.builtins.diagnostics.eslint,
-- null_ls.builtins.formatting.eslint, -- null_ls.builtins.formatting.eslint,
null_ls.builtins.diagnostics.stylelint, null_ls.builtins.diagnostics.stylelint,
null_ls.builtins.formatting.stylelint, null_ls.builtins.formatting.stylelint,
null_ls.builtins.formatting.rustywind, null_ls.builtins.formatting.rustywind,
-- Markdown -- Markdown
null_ls.builtins.formatting.remark, null_ls.builtins.formatting.remark,
-- Lua -- Lua
-- null_ls.builtins.diagnostics.luacheck, -- null_ls.builtins.diagnostics.luacheck,
null_ls.builtins.formatting.stylua, null_ls.builtins.formatting.stylua,
-- Python -- Python
null_ls.builtins.diagnostics.flake8, null_ls.builtins.diagnostics.flake8,
null_ls.builtins.formatting.black, null_ls.builtins.formatting.black,
null_ls.builtins.formatting.isort, null_ls.builtins.formatting.isort,
-- PHP -- PHP
null_ls.builtins.diagnostics.phpstan, null_ls.builtins.diagnostics.phpstan,
-- Go -- Go
null_ls.builtins.formatting.gofmt, null_ls.builtins.formatting.gofmt,
-- Rust -- Rust
null_ls.builtins.formatting.rustfmt, null_ls.builtins.formatting.rustfmt,
}, },
}) })
vim.api.nvim_create_autocmd("LspAttach", { vim.api.nvim_create_autocmd("LspAttach", {
callback = function(args) callback = function(args)
vim.bo[args.buf].formatexpr = nil vim.bo[args.buf].formatexpr = nil
end, end,
}) })
require("nvim-lightbulb").setup({ require("nvim-lightbulb").setup({
autocmd = { autocmd = {
enabled = false, enabled = false,
}, },
sign = { sign = {
enabled = false, enabled = false,
}, },
virtual_text = { virtual_text = {
enabled = false, enabled = false,
}, },
}) })
require("fidget").setup({}) require("fidget").setup({})

@ -1,89 +1,85 @@
local wk = require("which-key") local wk = require("which-key")
wk.register({ wk.register({
o = { o = {
p = { "<cmd>NvimTreeToggle<CR>", "Open project sidebar" }, p = { "<cmd>NvimTreeToggle<CR>", "Open project sidebar" },
}, },
}, { }, {
prefix = "<leader>", prefix = "<leader>",
}) })
require("nvim-tree").setup({ require("nvim-tree").setup({
auto_reload_on_write = true, auto_reload_on_write = true,
create_in_closed_folder = false, create_in_closed_folder = false,
disable_netrw = false, disable_netrw = false,
hijack_netrw = true, hijack_netrw = true,
hijack_unnamed_buffer_when_opening = false, hijack_unnamed_buffer_when_opening = false,
ignore_buffer_on_setup = false, open_on_tab = false,
open_on_setup = false, sort_by = "name",
open_on_setup_file = false, update_cwd = true,
open_on_tab = false, reload_on_bufenter = false,
sort_by = "name", respect_buf_cwd = true,
update_cwd = true, hijack_cursor = false,
reload_on_bufenter = false, update_focused_file = {
respect_buf_cwd = true, enable = true,
ignore_ft_on_setup = {}, update_cwd = true,
hijack_cursor = false, ignore_list = {},
update_focused_file = { },
enable = true, system_open = {
update_cwd = true, cmd = nil,
ignore_list = {}, args = {},
}, },
system_open = { view = {
cmd = nil, width = 30,
args = {}, side = "left",
}, signcolumn = "no",
view = { mappings = {
width = 30, custom_only = false,
side = "left", list = {},
signcolumn = "no", },
mappings = { },
custom_only = false, git = {
list = {}, ignore = false,
}, },
}, renderer = {
git = { special_files = {},
ignore = false, group_empty = false,
}, highlight_git = true,
renderer = { icons = {
special_files = {}, git_placement = "before",
group_empty = false, show = {
highlight_git = true, file = true,
icons = { folder = true,
git_placement = "before", folder_arrow = true,
show = { git = true,
file = true, },
folder = true, glyphs = {
folder_arrow = true, default = "",
git = true, symlink = "",
}, git = {
glyphs = { unstaged = "",
default = "", staged = "",
symlink = "", unmerged = "",
git = { renamed = "",
unstaged = "", untracked = "",
staged = "", deleted = "",
unmerged = "", ignored = "",
renamed = "", },
untracked = "", },
deleted = "", },
ignored = "", },
}, diagnostics = {
}, enable = false,
}, show_on_dirs = false,
}, icons = {
diagnostics = { hint = "",
enable = false, info = "",
show_on_dirs = false, warning = "",
icons = { error = "",
hint = "", },
info = "", },
warning = "", trash = {
error = "", cmd = "trash",
}, require_confirm = true,
}, },
trash = {
cmd = "trash",
require_confirm = true,
},
}) })

@ -74,7 +74,7 @@ wk.register({
f = { f = {
f = { "<cmd>Telescope find_files<cr>", "Find file" }, f = { "<cmd>Telescope find_files<cr>", "Find file" },
p = { p = {
[[<cmd>lua require('telescope.builtin').find_files{ cwd = '~/.config/nvim/' }<CR>]], [[<cmd>lua require('telescope.builtin').git_files{ cwd = '~/.config/nvim/' }<CR>]],
"Find config file", "Find config file",
}, },
o = { "<cmd>Telescope oldfiles<cr>", "Open recent file" }, o = { "<cmd>Telescope oldfiles<cr>", "Open recent file" },

@ -1,15 +0,0 @@
require("mason").setup()
require("mason-tool-installer").setup({
ensure_installed = {
"stylua",
"shellcheck",
"shfmt",
"editorconfig-checker",
"eslint_d",
"prettier",
"prettierd",
"flake8",
"black",
},
})
Loading…
Cancel
Save