Run some linting on nvim lua

This commit is contained in:
ViViDboarder 2021-09-15 18:13:17 -07:00
parent 4d4b6134d0
commit 9bbe68013b
12 changed files with 65 additions and 62 deletions

View File

@ -1,7 +1,10 @@
-- luacheck: globals packer_plugins
local utils = require("utils")
local map = vim.api.nvim_set_keymap
local opt_silent = {silent=true}
local opt_default = {silent=true, noremap=true}
local opt_silent = {silent = true}
local opt_default = {silent = true, noremap = true}
map("n", "<C-L><C-L>", ":set wrap!<CR>", opt_silent)
map("n", "<leader>lw", ":set wrap!<CR>", opt_silent)
map("n", "<C-N><C-N>", ":set invnumber<CR>", opt_silent)
@ -42,15 +45,15 @@ map("i", "``", "<esc>", opt_default)
map("v", "``", "<esc>", opt_default)
-- C-Space completion
_G.complete_space = function()
function _G.complete_space()
if vim.fn.pumvisible() == 1 then
return utils.t"<C-n>"
return utils.t("<C-n>")
elseif packer_plugins["completion-nvim"] and packer_plugins["completion-nvim"].loaded then
return utils.t"<Plug>(completion_trigger)"
return utils.t("<Plug>(completion_trigger)")
elseif packer_plugins["nvim-compe"] and packer_plugins["nvim-compe"].loaded then
return vim.fn["compe#complete"]()
else
return utils.t"<C-x><C-o>"
return utils.t("<C-x><C-o>")
end
end
map("i", "<C-Space>", "v:lua.complete_space()", {expr = true})

View File

@ -1,7 +1,8 @@
utils = require("utils")
-- luacheck: globals packer_plugins
local utils = require("utils")
-- TODO: Determine if I want to keep this or remove it in favor of dark-notify
_G.update_colors = function()
function _G.update_colors()
local function maybe_set(scope, name, val)
if vim[scope][name] ~= val then
vim[scope][name] = val
@ -39,7 +40,8 @@ _G.update_colors = function()
-- Update status line theme
if change and vim.fn.exists(":AirlineRefresh") == 1 then
vim.cmd(":AirlineRefresh")
elseif change and _G["packer_plugins"] ~= nil and packer_plugins["lualine"] and packer_plugins["lualine"].loaded then
elseif (change and _G["packer_plugins"]
and packer_plugins["lualine"] and packer_plugins["lualine"].loaded) then
local lualine_theme = vim.g.colors_name
if lualine_theme == "solarized" then
lualine_theme = lualine_theme .. "_" .. mode
@ -47,10 +49,10 @@ _G.update_colors = function()
require("plugins.lualine").config_lualine(lualine_theme)
end
return changed and "Changed color to " .. env_color .. " with mode " .. mode or "No change"
return change and "Changed color to " .. env_color .. " with mode " .. mode or "No change"
end
-- utils.autocmd("auto_colors", "FocusGained * call v:lua.update_colors()")
-- Initial set of colors
-- TODO: if update_colors() is removed, use the env color fetching and set the colorscheme here
update_colors()
_G.update_colors()

View File

@ -1,6 +1,4 @@
local wo = vim.wo
local o = vim.o
local bo = vim.bo
local g = vim.g
-- Set leader to space

View File

@ -1,4 +1,4 @@
local o, wo, bo = vim.o, vim.wo, vim.bo
local o = vim.o
-- Helpers
require "_settings"

View File

@ -1,6 +1,4 @@
-- Do all Packer stuff
utils = require("utils")
local install_path = vim.fn.stdpath("data").."/site/pack/packer/start/packer.nvim"
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
@ -31,6 +29,7 @@ local function config_dark_notify()
end
return require('packer').startup(function()
-- luacheck: push globals use
use "wbthomason/packer.nvim"
-- Quality of life
@ -109,9 +108,9 @@ return require('packer').startup(function()
use {
"cormacrelf/dark-notify",
-- Download latest release on install
run = "curl -s https://api.github.com/repos/cormacrelf/dark-notify/releases/latest | jq '.assets[].browser_download_url' | xargs curl -Ls | tar xz -C ~/.local/bin/",
run = "curl -s https://api.github.com/repos/cormacrelf/dark-notify/releases/latest | jq '.assets[].browser_download_url' | xargs curl -Ls | tar xz -C ~/.local/bin/", -- luacheck: no max line length
config = config_dark_notify,
requires = { "hoob3rt/lualine.nvim" },
requires = "hoob3rt/lualine.nvim",
}
use {
'mhinz/vim-startify',
@ -125,7 +124,7 @@ return require('packer').startup(function()
}
use {
"glepnir/lspsaga.nvim",
requires = { "neovim/nvim-lspconfig" },
requires = "neovim/nvim-lspconfig",
}
--[[
use {
@ -167,9 +166,7 @@ return require('packer').startup(function()
-- Fuzzy Finder
use {
"nvim-telescope/telescope.nvim",
requires = {
"nvim-lua/plenary.nvim",
},
requires = "nvim-lua/plenary.nvim",
config = function() require("plugins.telescope") end,
}
--[[
@ -187,7 +184,7 @@ return require('packer').startup(function()
-- Override key commands
-- vim.g.fzf_action = { ['ctrl-t'] = 'tab split', ['ctrl-s'] = 'split', ['ctrl-v'] = 'vsplit', }
-- Override git log to show authors
vim.g.fzf_commits_log_options = '--graph --color=always --format="%C(auto)%h %an: %s%d %C(black)%C(bold)%cr"'
vim.g.fzf_commits_log_options = '--graph --color=always --format="%C(auto)%h %an: %s%d %C(black)%C(bold)%cr"' -- luacheck: no max line length
vim.g.fzf_preview_window = {"right:50%", "ctrl-/"}
@ -246,4 +243,5 @@ return require('packer').startup(function()
cmd = { "StartupTime" },
}
-- luacheck: pop
end)

View File

@ -1,28 +1,28 @@
local function config_airline()
-- Use short-form mode text
vim.g.airline_mode_map = {
['__'] = '-',
['n'] = 'N',
['i'] = 'I',
['R'] = 'R',
['c'] = 'C',
['v'] = 'V',
['V'] = 'V',
[''] = 'V',
['s'] = 'S',
['S'] = 'S',
[''] = 'S',
['t'] = 'T',
["__"] = "-",
["n"] = "N",
["i"] = "I",
["R"] = "R",
["c"] = "C",
["v"] = "V",
["V"] = "V",
[""] = "V",
["s"] = "S",
["S"] = "S",
[""] = "S",
["t"] = "T",
}
-- abbreviate trailing whitespace and mixed indent
vim.g["airline#extensions#whitespace#trailing_format"] = "tw[%s]"
vim.g["airline#extensions#whitespace#mixed_indent_format"] = "i[%s]"
-- Vertical separators for all
vim.g.airline_left_sep=''
vim.g.airline_left_alt_sep=''
vim.g.airline_right_sep=''
vim.g.airline_right_alt_sep=''
vim.g.airline_left_sep=""
vim.g.airline_left_alt_sep=""
vim.g.airline_right_sep=""
vim.g.airline_right_alt_sep=""
vim.g["airline#extensions#tabline#enabled"] = 1
vim.g["airline#extensions#tabline#left_sep"] = " "
vim.g["airline#extensions#tabline#left_alt_sep"] = "|"

View File

@ -1,16 +1,16 @@
vim.g["airline#extensions#ale#enabled"] = 1
vim.g.ale_lint_on_enter = 0
vim.g.ale_linters = {
-- go = { 'gopls', 'golint', 'golangci-lint' },
go = { "golangci-lint" },
-- rust = { 'rls', 'cargo' },
rust = { "cargo" },
-- sh = { 'language_server', 'shell', 'shellcheck' },
sh = { "shell", "shellcheck" },
text = { "proselint", "alex" },
-- go = {'gopls', 'golint', 'golangci-lint'},
go = {"golangci-lint"},
-- rust = {'rls', 'cargo'},
rust = {"cargo"},
-- sh = {'language_server', 'shell', 'shellcheck'},
sh = {"shell", "shellcheck"},
text = {"proselint", "alex"},
}
vim.g.ale_linter_aliases = {
markdown = { "text" },
markdown = {"text"},
}
local pretty_trim_fixer = {
"prettier",
@ -18,10 +18,10 @@ local pretty_trim_fixer = {
"remove_trailing_lines"
}
vim.g.ale_fixers = {
["*"] = { "trim_whitespace", "remove_trailing_lines" },
-- go = { "gofmt", "goimports" },
["*"] = {"trim_whitespace", "remove_trailing_lines"},
-- go = {"gofmt", "goimports"},
json = pretty_trim_fixer,
-- rust = { "rustfmt" },
-- rust = {"rustfmt"},
--[[
python = {
"black",
@ -32,7 +32,7 @@ vim.g.ale_fixers = {
},
--]]
markdown = pretty_trim_fixer,
yaml = { "prettier", "remove_trailing_lines" },
yaml = {"prettier", "remove_trailing_lines"},
css = pretty_trim_fixer,
javascript = pretty_trim_fixer,
}

View File

@ -1,3 +1,4 @@
-- luacheck: globals packer_plugins
local function default_attach(client, bufnr)
require('completion').on_attach()
@ -7,6 +8,7 @@ local function default_attach(client, bufnr)
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings
-- TODO: Maybe prefix all of these for easier discovery
local opts = { noremap=true, silent=true }
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)

View File

@ -1,6 +1,6 @@
vim.g.startify_list_order = {
{ ' My Bookmarks'}, 'bookmarks',
{ ' Most recently used files in the current directory' }, 'dir',
{ ' Most recently used files' }, 'files',
{ ' My Sessions' }, 'sessions'
{' My Bookmarks'}, 'bookmarks',
{' Most recently used files in the current directory'}, 'dir',
{' Most recently used files'}, 'files',
{' My Sessions'}, 'sessions'
}

View File

@ -21,7 +21,7 @@ local function config_telescope()
layout_strategy = "flex",
}
}
opts = {silent=true, noremap=true}
local opts = {silent=true, noremap=true}
vim.api.nvim_set_keymap("n", "<C-t>", "<cmd>Telescope find_files<CR>", opts)
vim.api.nvim_set_keymap("n", "<leader>ff", "<cmd>Telescope find_files<CR>", opts)
vim.api.nvim_set_keymap("n", "<leader>fh", "<cmd>Telescope help_tags<CR>", opts)

View File

@ -1,9 +1,9 @@
-- Configures nvim-treesitter
require'nvim-treesitter.configs'.setup{
incremental_selection = { enable = true },
incremental_selection = {enable = true},
-- Indent appears to be broken right now
indent = { enable = false },
textobjects = { enable = true },
indent = {enable = false},
textobjects = {enable = true},
highlight = {
enable = true,
disable = {},

View File

@ -44,7 +44,7 @@ end
-- Get env value or use default, if not present
function M.env_default(name, def)
val = vim.env[name]
local val = vim.env[name]
return val == nil and def or val
end
@ -80,8 +80,8 @@ function M.require_with_local(name)
-- In that case, the local file would probably start with a `require` for the
-- non-local version. This would allow more control but at the cost of a bit
-- of boiler plate
rmod = require(name)
lmod = M.maybe_require(name .. "_local")
local rmod = require(name)
local lmod = M.maybe_require(name .. "_local")
if lmod ~= nil then
return lmod
end