Added building via shell in neovim
Display diagnostics inline to buffer List compile errors/warnings in quickfix list Added 'push' command to install script Make sure install script executes from the correct directory
This commit is contained in:
@@ -59,6 +59,90 @@ vim.opt.listchars:append({ lead = "." })
|
||||
-- Functions
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- Building & Errors
|
||||
|
||||
-- Diagnostics configuration
|
||||
vim.diagnostic.config({
|
||||
signs = {
|
||||
text = {
|
||||
[vim.diagnostic.severity.ERROR] = "",
|
||||
[vim.diagnostic.severity.WARN] = ""
|
||||
},
|
||||
linehl = {
|
||||
[vim.diagnostic.severity.ERROR] = "DiagnosticLineError",
|
||||
[vim.diagnostic.severity.WARN] = "DiagnosticLineWarn"
|
||||
},
|
||||
},
|
||||
virtual_text = {
|
||||
virt_text_pos = "eol_right_align",
|
||||
prefix =
|
||||
function(d, i, total)
|
||||
return d.severity == vim.diagnostic.severity.ERROR and "!" or "#"
|
||||
end
|
||||
},
|
||||
underline = false,
|
||||
severity_sort = true
|
||||
})
|
||||
|
||||
local _last_build = ""
|
||||
local _quickfix = {}
|
||||
local _namespace = vim.api.nvim_create_namespace("__qf.buffer.errors")
|
||||
|
||||
local function LoadDiagnostics(args)
|
||||
local bufnr = args.buf
|
||||
|
||||
if _quickfix[bufnr] then
|
||||
vim.diagnostic.set(_namespace, bufnr, _quickfix[bufnr])
|
||||
end
|
||||
end
|
||||
|
||||
local function ExecuteBuild()
|
||||
vim.cmd("silent make")
|
||||
|
||||
-- Reset currently displayed diagnostics
|
||||
_quickfix = {}
|
||||
vim.diagnostic.reset()
|
||||
|
||||
local entries = vim.fn.getqflist()
|
||||
if #entries ~= 0 then
|
||||
-- Group diagnostics by buffer number
|
||||
local diagnostics = vim.diagnostic.fromqflist(entries)
|
||||
for _, d in ipairs(diagnostics) do
|
||||
if not _quickfix[d.bufnr] then
|
||||
_quickfix[d.bufnr] = {}
|
||||
end
|
||||
|
||||
table.insert(_quickfix[d.bufnr], d)
|
||||
end
|
||||
|
||||
-- Display the new diagnostics
|
||||
for it, v in pairs(_quickfix) do
|
||||
vim.diagnostic.set(_namespace, it, v)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function PromptBuild()
|
||||
vim.ui.input(
|
||||
{
|
||||
prompt = "Compile: ",
|
||||
completion = "shellcmdline",
|
||||
default = _last_build
|
||||
},
|
||||
function(input)
|
||||
if input ~= nil then
|
||||
local makeprg = vim.o.makeprg
|
||||
vim.o.makeprg = input
|
||||
|
||||
ExecuteBuild()
|
||||
|
||||
_last_build = input
|
||||
vim.o.makeprg = makeprg
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
-- Buffers
|
||||
|
||||
local function BufferComplete()
|
||||
@@ -185,6 +269,7 @@ MAP("i", "<S-Tab>", "<C-o><<")
|
||||
MAP("i", "<Tab>", BufferComplete, { expr = true })
|
||||
MAP("n", "<Leader>s", ManageSplit)
|
||||
MAP("n", "<Leader>f", ProjectSearch)
|
||||
MAP("n", "<Leader>m", PromptBuild)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Autocommands
|
||||
@@ -193,8 +278,9 @@ MAP("n", "<Leader>f", ProjectSearch)
|
||||
AUTOCMD('BufEnter', { command = "let b:man_default_sects=\"2,3\"", pattern = "*.c" })
|
||||
AUTOCMD('BufReadPost', { command = "setlocal nornu", pattern = "quickfix" })
|
||||
|
||||
AUTOCMD('BufWritePre', { callback = TrimBuffer, pattern = "*" })
|
||||
AUTOCMD('VimEnter', { callback = MakeScratch, pattern = "*" })
|
||||
AUTOCMD('BufWinEnter', { callback = LayoutHelp, pattern = "*" })
|
||||
AUTOCMD('WinEnter', { callback = ExpandHelp, pattern = "*" })
|
||||
AUTOCMD('WinLeave', { callback = ExpandHelp, pattern = "*" })
|
||||
AUTOCMD('BufWritePre', { callback = TrimBuffer, pattern = "*" })
|
||||
AUTOCMD('VimEnter', { callback = MakeScratch, pattern = "*" })
|
||||
AUTOCMD('BufWinEnter', { callback = LayoutHelp, pattern = "*" })
|
||||
AUTOCMD('WinEnter', { callback = ExpandHelp, pattern = "*" })
|
||||
AUTOCMD('WinLeave', { callback = ExpandHelp, pattern = "*" })
|
||||
AUTOCMD('BufRead', { callback = LoadDiagnostics, pattern = "*" })
|
||||
|
||||
19
install
19
install
@@ -1,6 +1,18 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
pushd "$(dirname $0)" > /dev/null
|
||||
|
||||
Push() {
|
||||
# Installs current dotfiles onto the system
|
||||
#
|
||||
echo "[Info] :: Installing dotfiles into $1"
|
||||
|
||||
[[ ! -d "$1" ]] && mkdir -p "$1"
|
||||
|
||||
cp -RT "config" "$1/.config"
|
||||
}
|
||||
|
||||
Pull() {
|
||||
# Allows system changes to be pulled into the repository to be committed
|
||||
#
|
||||
@@ -10,11 +22,14 @@ Pull() {
|
||||
}
|
||||
|
||||
INSTALL_DIR=${2:-$HOME}
|
||||
ACTION=${1:-push}
|
||||
ACTION=$1
|
||||
|
||||
[[ -z $INSTALL_DIR ]] && echo "[Error] :: Installation directory not set" && exit 1
|
||||
|
||||
case $ACTION in
|
||||
push)
|
||||
Push $INSTALL_DIR
|
||||
;;
|
||||
pull)
|
||||
Pull $INSTALL_DIR
|
||||
;;
|
||||
@@ -22,3 +37,5 @@ case $ACTION in
|
||||
echo "usage: $0 <push|pull|diff> [dir]"
|
||||
;;
|
||||
esac
|
||||
|
||||
popd > /dev/null
|
||||
|
||||
Reference in New Issue
Block a user