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 map = vim.api.nvim_set_keymap
local opt_silent = {silent=true} local opt_silent = {silent = true}
local opt_default = {silent=true, noremap=true} local opt_default = {silent = true, noremap = true}
map("n", "<C-L><C-L>", ":set wrap!<CR>", opt_silent) map("n", "<C-L><C-L>", ":set wrap!<CR>", opt_silent)
map("n", "<leader>lw", ":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) 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) map("v", "``", "<esc>", opt_default)
-- C-Space completion -- C-Space completion
_G.complete_space = function() function _G.complete_space()
if vim.fn.pumvisible() == 1 then 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 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 elseif packer_plugins["nvim-compe"] and packer_plugins["nvim-compe"].loaded then
return vim.fn["compe#complete"]() return vim.fn["compe#complete"]()
else else
return utils.t"<C-x><C-o>" return utils.t("<C-x><C-o>")
end end
end end
map("i", "<C-Space>", "v:lua.complete_space()", {expr = true}) 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 -- 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) local function maybe_set(scope, name, val)
if vim[scope][name] ~= val then if vim[scope][name] ~= val then
vim[scope][name] = val vim[scope][name] = val
@ -39,7 +40,8 @@ _G.update_colors = function()
-- Update status line theme -- Update status line theme
if change and vim.fn.exists(":AirlineRefresh") == 1 then if change and vim.fn.exists(":AirlineRefresh") == 1 then
vim.cmd(":AirlineRefresh") 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 local lualine_theme = vim.g.colors_name
if lualine_theme == "solarized" then if lualine_theme == "solarized" then
lualine_theme = lualine_theme .. "_" .. mode lualine_theme = lualine_theme .. "_" .. mode
@ -47,10 +49,10 @@ _G.update_colors = function()
require("plugins.lualine").config_lualine(lualine_theme) require("plugins.lualine").config_lualine(lualine_theme)
end 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 end
-- utils.autocmd("auto_colors", "FocusGained * call v:lua.update_colors()") -- utils.autocmd("auto_colors", "FocusGained * call v:lua.update_colors()")
-- Initial set of colors -- Initial set of colors
-- TODO: if update_colors() is removed, use the env color fetching and set the colorscheme here -- 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 o = vim.o
local bo = vim.bo
local g = vim.g local g = vim.g
-- Set leader to space -- 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 -- Helpers
require "_settings" require "_settings"

View File

@ -1,6 +1,4 @@
-- Do all Packer stuff -- Do all Packer stuff
utils = require("utils")
local install_path = vim.fn.stdpath("data").."/site/pack/packer/start/packer.nvim" local install_path = vim.fn.stdpath("data").."/site/pack/packer/start/packer.nvim"
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
@ -31,6 +29,7 @@ local function config_dark_notify()
end end
return require('packer').startup(function() return require('packer').startup(function()
-- luacheck: push globals use
use "wbthomason/packer.nvim" use "wbthomason/packer.nvim"
-- Quality of life -- Quality of life
@ -109,9 +108,9 @@ return require('packer').startup(function()
use { use {
"cormacrelf/dark-notify", "cormacrelf/dark-notify",
-- Download latest release on install -- 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, config = config_dark_notify,
requires = { "hoob3rt/lualine.nvim" }, requires = "hoob3rt/lualine.nvim",
} }
use { use {
'mhinz/vim-startify', 'mhinz/vim-startify',
@ -125,7 +124,7 @@ return require('packer').startup(function()
} }
use { use {
"glepnir/lspsaga.nvim", "glepnir/lspsaga.nvim",
requires = { "neovim/nvim-lspconfig" }, requires = "neovim/nvim-lspconfig",
} }
--[[ --[[
use { use {
@ -167,9 +166,7 @@ return require('packer').startup(function()
-- Fuzzy Finder -- Fuzzy Finder
use { use {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
requires = { requires = "nvim-lua/plenary.nvim",
"nvim-lua/plenary.nvim",
},
config = function() require("plugins.telescope") end, config = function() require("plugins.telescope") end,
} }
--[[ --[[
@ -187,7 +184,7 @@ return require('packer').startup(function()
-- Override key commands -- Override key commands
-- vim.g.fzf_action = { ['ctrl-t'] = 'tab split', ['ctrl-s'] = 'split', ['ctrl-v'] = 'vsplit', } -- vim.g.fzf_action = { ['ctrl-t'] = 'tab split', ['ctrl-s'] = 'split', ['ctrl-v'] = 'vsplit', }
-- Override git log to show authors -- 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-/"} vim.g.fzf_preview_window = {"right:50%", "ctrl-/"}
@ -246,4 +243,5 @@ return require('packer').startup(function()
cmd = { "StartupTime" }, cmd = { "StartupTime" },
} }
-- luacheck: pop
end) end)

View File

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

View File

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

View File

@ -1,3 +1,4 @@
-- luacheck: globals packer_plugins
local function default_attach(client, bufnr) local function default_attach(client, bufnr)
require('completion').on_attach() require('completion').on_attach()
@ -7,6 +8,7 @@ local function default_attach(client, bufnr)
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings -- Mappings
-- TODO: Maybe prefix all of these for easier discovery
local opts = { noremap=true, silent=true } 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.declaration()<CR>', opts)
buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<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 = { vim.g.startify_list_order = {
{ ' My Bookmarks'}, 'bookmarks', {' My Bookmarks'}, 'bookmarks',
{ ' Most recently used files in the current directory' }, 'dir', {' Most recently used files in the current directory'}, 'dir',
{ ' Most recently used files' }, 'files', {' Most recently used files'}, 'files',
{ ' My Sessions' }, 'sessions' {' My Sessions'}, 'sessions'
} }

View File

@ -21,7 +21,7 @@ local function config_telescope()
layout_strategy = "flex", 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", "<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>ff", "<cmd>Telescope find_files<CR>", opts)
vim.api.nvim_set_keymap("n", "<leader>fh", "<cmd>Telescope help_tags<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 -- Configures nvim-treesitter
require'nvim-treesitter.configs'.setup{ require'nvim-treesitter.configs'.setup{
incremental_selection = { enable = true }, incremental_selection = {enable = true},
-- Indent appears to be broken right now -- Indent appears to be broken right now
indent = { enable = false }, indent = {enable = false},
textobjects = { enable = true }, textobjects = {enable = true},
highlight = { highlight = {
enable = true, enable = true,
disable = {}, disable = {},

View File

@ -44,7 +44,7 @@ end
-- Get env value or use default, if not present -- Get env value or use default, if not present
function M.env_default(name, def) function M.env_default(name, def)
val = vim.env[name] local val = vim.env[name]
return val == nil and def or val return val == nil and def or val
end 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 -- 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 -- non-local version. This would allow more control but at the cost of a bit
-- of boiler plate -- of boiler plate
rmod = require(name) local rmod = require(name)
lmod = M.maybe_require(name .. "_local") local lmod = M.maybe_require(name .. "_local")
if lmod ~= nil then if lmod ~= nil then
return lmod return lmod
end end