[nvim] cleanup: format all files through LSP

This commit is contained in:
David JULIEN 2023-02-19 17:23:52 +01:00
parent 0e1e60f532
commit 34dc364d9f
8 changed files with 77 additions and 75 deletions

View File

@ -36,7 +36,7 @@ vim.keymap.set({ "t" }, "<leader><Esc>",
-- yank and pasting -- yank and pasting
vim.keymap.set({ "n", "x" }, "<leader>y", vim.keymap.set({ "n", "x" }, "<leader>y",
"\"+y", "\"+y",
{ desc = "Yank to clipboard"} { desc = "Yank to clipboard" }
) )
vim.keymap.set("n", "<leader>p", vim.keymap.set("n", "<leader>p",
"\"+P", "\"+P",
@ -95,9 +95,11 @@ vim.keymap.set("n", "<leader>tk",
{ desc = "Search through keymaps" } { desc = "Search through keymaps" }
) )
vim.keymap.set("n", "<leader>tx", vim.keymap.set("n", "<leader>tx",
function() require("telescope.builtin").diagnostics( function()
{ buffnr = 0 } require("telescope.builtin").diagnostics(
) end, { buffnr = 0 }
)
end,
{ desc = "Search through LSP diagnostics" } { desc = "Search through LSP diagnostics" }
) )

View File

@ -5,6 +5,7 @@
local M = {} local M = {}
M.setup = function(opts) end M.setup = function(opts)
end
return M return M

View File

@ -24,7 +24,6 @@ return {
"williamboman/mason-lspconfig.nvim", "williamboman/mason-lspconfig.nvim",
}, },
config = function() config = function()
vim.diagnostic.config({ vim.diagnostic.config({
underline = true, underline = true,
update_in_insert = false, update_in_insert = false,

View File

@ -33,13 +33,13 @@ M.setup = function(opts)
workspace = { workspace = {
-- Make the server aware of Neovim runtime files -- Make the server aware of Neovim runtime files
library = library =
vim.api.nvim_get_runtime_file("", true), vim.api.nvim_get_runtime_file("", true),
checkThirdParty = false, checkThirdParty = false,
}, },
-- Do not send telemetry data containing a randomized but -- Do not send telemetry data containing a randomized but
-- unique identifier -- unique identifier
telemetry = { telemetry = {
enable = false, enable = false,
}, },
}, },
} }

View File

@ -15,4 +15,3 @@ M.setup = function(opts)
end end
return M return M

View File

@ -6,6 +6,7 @@
local M = {} local M = {}
M.setup = function(opts) end M.setup = function(opts)
end
return M return M

View File

@ -3,68 +3,68 @@
-- License : GPLv3 -- License : GPLv3
-- Description : neovim settings file -- Description : neovim settings file
local opt = vim.opt local opt = vim.opt
local g = vim.g local g = vim.g
-- general -- general
opt.wildignore = { opt.wildignore = {
".git", ".git",
"*.o", "*.class", "*.o", "*.class",
"*.jpg", "*.jpeg", "*.png", "*.jpg", "*.jpeg", "*.png",
"*.pdf", "*.pdf",
"*.zip", "*.gz", "*.rar", "*.tar.xz", "*.zip", "*.gz", "*.rar", "*.tar.xz",
} }
opt.wildmode = { "longest", "full" } opt.wildmode = { "longest", "full" }
opt.wildoptions = "pum" opt.wildoptions = "pum"
-- editor -- editor
opt.lazyredraw = true opt.lazyredraw = true
opt.splitright = true opt.splitright = true
opt.splitbelow = true opt.splitbelow = true
opt.scrolloff = 4 opt.scrolloff = 4
opt.termguicolors = true opt.termguicolors = true
opt.background = "dark" opt.background = "dark"
opt.cursorline = true opt.cursorline = true
opt.colorcolumn = "+1" opt.colorcolumn = "+1"
opt.shortmess = opt.shortmess:append { c = true } opt.shortmess = opt.shortmess:append { c = true }
opt.number = true opt.number = true
opt.relativenumber = true opt.relativenumber = true
opt.signcolumn = "yes" opt.signcolumn = "yes"
opt.listchars = { opt.listchars = {
tab = "<->", tab = "<->",
nbsp = "", nbsp = "",
trail = "·", trail = "·",
extends = ">", extends = ">",
precedes = "<", precedes = "<",
} }
opt.showmatch = true opt.showmatch = true
opt.ignorecase = true opt.ignorecase = true
opt.smartcase = true opt.smartcase = true
opt.inccommand = "split" opt.inccommand = "split"
opt.completeopt = { "menuone", "noselect" } opt.completeopt = { "menuone", "noselect" }
-- statusline -- statusline
opt.laststatus = 2 opt.laststatus = 2
opt.showmode = false opt.showmode = false
-- text, tabs, indents -- text, tabs, indents
opt.textwidth = 79 opt.textwidth = 79
opt.tabstop = 4 opt.tabstop = 4
opt.softtabstop = -1 opt.softtabstop = -1
opt.expandtab = true opt.expandtab = true
opt.shiftwidth = 0 opt.shiftwidth = 0
opt.backspace = { "indent", "eol", "start" } opt.backspace = { "indent", "eol", "start" }
-- augroups -- augroups
utils.create_augroup({ utils.create_augroup({
{"BufWritePre", "*", "%s/\\s\\+$//e"} { "BufWritePre", "*", "%s/\\s\\+$//e" }
}, "remove_trailing_whitespaces") }, "remove_trailing_whitespaces")
utils.create_augroup({ utils.create_augroup({
{"BufNewFile,BufRead", "*.mom", "set filetype=groff"}, { "BufNewFile,BufRead", "*.mom", "set filetype=groff" },
{"BufNewFile,BufRead", "*.tex", "set filetype=tex"}, { "BufNewFile,BufRead", "*.tex", "set filetype=tex" },
}, "enforce_filetypes") }, "enforce_filetypes")
vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, { vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
pattern = {"*.njk"}, pattern = { "*.njk" },
callback = function() vim.bo.filetype="html" end, callback = function() vim.bo.filetype = "html" end,
}) })

View File

@ -8,40 +8,40 @@ local cmd = vim.cmd
-- augroup helper -- augroup helper
function M.create_augroup(autocmds, name) function M.create_augroup(autocmds, name)
cmd("augroup " .. name) cmd("augroup " .. name)
cmd("autocmd!") cmd("autocmd!")
for _, autocmd in ipairs(autocmds) do for _, autocmd in ipairs(autocmds) do
cmd("autocmd " .. table.concat(autocmd, " ")) cmd("autocmd " .. table.concat(autocmd, " "))
end end
cmd("augroup END") cmd("augroup END")
end end
-- add a path to the rtp -- add a path to the rtp
function M.add_rtp(path) function M.add_rtp(path)
local rtp = vim.o.rtp local rtp = vim.o.rtp
rtp = rtp .. "," .. path rtp = rtp .. "," .. path
end end
-- see if a file exists -- see if a file exists
function M.file_exists(file) function M.file_exists(file)
local f = io.open(file, "rb") local f = io.open(file, "rb")
if f then f:close() end if f then f:close() end
return f ~= nil return f ~= nil
end end
-- get all lines from a file -- get all lines from a file
-- @return table (empty if the file does not exist) -- @return table (empty if the file does not exist)
function M.lines_from(file) function M.lines_from(file)
if not M.file_exists(file) then return {} end if not M.file_exists(file) then return {} end
local lines = {} local lines = {}
for line in io.lines(file) do for line in io.lines(file) do
lines[#lines] = line lines[#lines] = line
end end
return lines return lines
end end
function M.copy(args) function M.copy(args)
return args[1] return args[1]
end end
-- Make it accessible everywhere -- Make it accessible everywhere