From ceb46755cd0e962d2d15d4cb63e299ebb3ee03cc Mon Sep 17 00:00:00 2001 From: FollieHiyuki Date: Tue, 19 Oct 2021 03:03:00 +0700 Subject: [PATCH] neovim - plugins: add dial.nvim, remove spellsitter.nvim - null-ls.nvim: make a list of interesting linters/formatters - chore: add luacheck --- home/.config/nvim/.luacheckrc | 3 + home/.config/nvim/lua/mappings.lua | 2 +- home/.config/nvim/lua/modules/editor.lua | 61 +++++++++++++-- home/.config/nvim/lua/modules/lsp.lua | 97 ++++++++++++++++++++++-- home/.config/nvim/lua/modules/ui.lua | 3 +- home/.config/nvim/lua/plugins.lua | 19 +++-- home/.config/nvim/scripts/hadolint | 4 + home/.config/nvim/scripts/lint/hadolint | 3 + 8 files changed, 166 insertions(+), 26 deletions(-) create mode 100644 home/.config/nvim/.luacheckrc create mode 100755 home/.config/nvim/scripts/hadolint create mode 100755 home/.config/nvim/scripts/lint/hadolint diff --git a/home/.config/nvim/.luacheckrc b/home/.config/nvim/.luacheckrc new file mode 100644 index 0000000..11c8e2e --- /dev/null +++ b/home/.config/nvim/.luacheckrc @@ -0,0 +1,3 @@ +std = 'min' +cache = true +new_globals = {'vim'} diff --git a/home/.config/nvim/lua/mappings.lua b/home/.config/nvim/lua/mappings.lua index f2e20fc..a3362af 100644 --- a/home/.config/nvim/lua/mappings.lua +++ b/home/.config/nvim/lua/mappings.lua @@ -8,7 +8,7 @@ local function pandoc_convert(ofiletype) local ifilename = vim.fn.expand('%:p') local ofilename = vim.fn.expand('%:p:r') .. '.' .. ofiletype - local cmd = nil + local cmd if ofiletype == 'pdf' then cmd = string.format('pandoc %s -o %s --pdf-engine=xelatex -V "mainfont:Iosevka Etoile" -V "sansfont:Iosevka Aile" -V "monofont:Iosevka" -V "geometry:margin=1in"', ifilename, ofilename) diff --git a/home/.config/nvim/lua/modules/editor.lua b/home/.config/nvim/lua/modules/editor.lua index fe89cd5..3473ea8 100644 --- a/home/.config/nvim/lua/modules/editor.lua +++ b/home/.config/nvim/lua/modules/editor.lua @@ -138,13 +138,6 @@ function M.treesitter_conf() vim.opt.foldexpr = 'nvim_treesitter#foldexpr()' end --- function M.spellsitter_conf() --- require('spellsitter').setup { --- hl = 'SpellBad', --- captures = {'comment'} --- } --- end - function M.iswap_conf() require('iswap').setup { -- The keys that will be used as a selection, in order @@ -259,6 +252,60 @@ function M.eft_conf() vim.api.nvim_set_keymap('x', ';', '(eft-repeat)', {}) end +function M.dial_conf() + local dial = require('dial') + + -- Custom augends + dial.augends['custom#boolean'] = dial.common.enum_cyclic{ + name = 'boolean', + strlist = {'true', 'false'} + } + dial.augends['custom#boolean2'] = dial.common.enum_cyclic{ + name = 'boolean', + strlist = {'True', 'False'} + } + + dial.config.searchlist.normal = { + 'number#decimal#int', + 'number#decimal#fixed#zero', + 'number#hex', + 'number#binary', + 'date#[%Y/%m/%d]', + 'date#[%m/%d]', + 'date#[%Y-%m-%d]', + 'date#[%H:%M:%S]', + 'date#[%H:%M]', + 'date#[%jA]', + 'color#hex', + 'markup#markdown#header', + 'custom#boolean', + 'custom#boolean2' + } + dial.config.searchlist.visual = { + 'number#decimal#int', + 'number#decimal#fixed#zero', + 'number#hex', + 'number#binary', + 'date#[%Y/%m/%d]', + 'date#[%m/%d]', + 'date#[%Y-%m-%d]', + 'date#[%H:%M:%S]', + 'date#[%H:%M]', + 'date#[%jA]', + 'char#alph#small#word', + 'char#alph#capital#word', + 'color#hex' + } + + -- Mappings + vim.api.nvim_set_keymap('n', '', '(dial-increment)', {}) + vim.api.nvim_set_keymap('v', '', '(dial-increment)', {}) + vim.api.nvim_set_keymap('n', '', '(dial-decrement)', {}) + vim.api.nvim_set_keymap('v', '', '(dial-decrement)', {}) + vim.api.nvim_set_keymap('v', 'g', '(dial-increment-additional)', {}) + vim.api.nvim_set_keymap('v', 'g', '(dial-decrement-additional)', {}) +end + function M.comment_conf() require('nvim_comment').setup {comment_empty = false} end diff --git a/home/.config/nvim/lua/modules/lsp.lua b/home/.config/nvim/lua/modules/lsp.lua index 353c0ee..13f156e 100644 --- a/home/.config/nvim/lua/modules/lsp.lua +++ b/home/.config/nvim/lua/modules/lsp.lua @@ -305,16 +305,97 @@ function M.lsp_conf() -- Register sources null_ls.config { sources = { - -- Formatters - null_ls.builtins.formatting.stylua.with { - condition = function(utils) - return utils.root_has_file('stylua.toml') - end - }, + -- Formatters -- + -- null_ls.builtins.formatting.black.with { + -- command = 'black' + -- }, null_ls.builtins.formatting.clang_format.with { filetypes = {'c', 'cpp'} - } - -- Linters + }, + -- null_ls.builtins.formatting.cmake_format.with { + -- command = 'cmake-format' + -- }, + -- null_ls.builtins.formatting.eslint.with { + -- condition = function(utils) + -- return utils.root_has_file('.eslintrc.js') + -- end, + -- command = 'eslint' + -- }, + null_ls.builtins.formatting.fish_indent, + -- null_ls.builtins.formatting.fixjson.with { + -- command = 'fixjson' + -- }, + -- null_ls.builtins.formatting.fnlfmt.with { + -- command = 'fnlfmt' + -- }, + -- null_ls.builtins.formatting.goimports.with { + -- command = 'goimports' + -- }, + -- null_ls.builtins.formatting.gofmt.with { + -- command = 'gofmt' + -- }, + -- null_ls.builtins.formatting.isort.with { + -- command = 'isort' + -- }, + -- null_ls.builtins.formatting.nixfmt.with { + -- command = 'nixfmt' + -- }, + -- null_ls.builtins.formatting.prettier.with { + -- command = 'prettier' + -- }, + -- null_ls.builtins.formatting.rustfmt.with { + -- command = 'rustfmt' + -- }, + -- null_ls.builtins.formatting.rustywind.with { + -- command = 'rustywind' + -- }, + -- null_ls.builtins.formatting.shfmt, + -- null_ls.builtins.formatting.stylua.with { + -- condition = function(utils) + -- return utils.root_has_file('stylua.toml') + -- end, + -- command = 'stylua' + -- }, + -- null_ls.builtins.formatting.uncrustify.with { + -- command = 'uncrustify' + -- }, + -- null_ls.builtins.formatting.yapf.with { + -- command = 'yapf' + -- }, + -- null_ls.builtins.formatting.autopep8.with { + -- command = 'autopep8' + -- }, + -- null_ls.builtins.formatting.stylelint.with { + -- command = 'stylelint' + -- }, + -- Linters -- + null_ls.builtins.diagnostics.shellcheck, + -- null_ls.builtins.diagnostics.codespell.with { + -- command = 'codespell' + -- }, + -- null_ls.builtins.diagnostics.eslint.with { + -- command = 'eslint' + -- }, + -- null_ls.builtins.diagnostics.flake8.with { + -- command = 'flake8' + -- }, + null_ls.builtins.diagnostics.hadolint.with { + command = vim.fn.stdpath('config') .. '/scripts/hadolint', + args = {'$FILENAME'} + }, + null_ls.builtins.diagnostics.luacheck, + -- null_ls.builtins.diagnostics.cppcheck, + -- null_ls.builtins.diagnostics.write_good, + -- null_ls.builtins.diagnostics.proselint, + -- null_ls.builtins.diagnostics.markdownlint, + -- null_ls.builtins.diagnostics.pylint, + -- null_ls.builtins.diagnostics.vale, + -- null_ls.builtins.diagnostics.misspell, + -- null_ls.builtins.diagnostics.vint, + -- null_ls.builtins.diagnostics.stylelint, + -- Special -- + null_ls.builtins.hover.dictionary, -- get word definition from dictionaryapi.dev + -- null_ls.builtins.code_actions.gitsigns } } diff --git a/home/.config/nvim/lua/modules/ui.lua b/home/.config/nvim/lua/modules/ui.lua index c6615b7..805e438 100644 --- a/home/.config/nvim/lua/modules/ui.lua +++ b/home/.config/nvim/lua/modules/ui.lua @@ -2,7 +2,6 @@ local M = {} function M.dashboard_conf() local dashboard = require('alpha.themes.dashboard') - local button = dashboard.button dashboard.section.header = { type = 'text', @@ -32,7 +31,7 @@ function M.dashboard_conf() } } - button = function(sc, txt, keybind, keybind_opts) + local button = function(sc, txt, keybind, keybind_opts) local sc_ = sc:gsub('%s', ''):gsub('SPC', '') local opts = { diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua index 0b27cf4..cda36fa 100644 --- a/home/.config/nvim/lua/plugins.lua +++ b/home/.config/nvim/lua/plugins.lua @@ -78,11 +78,6 @@ return packer.startup(function(use) use {'nvim-treesitter/playground', after = 'nvim-treesitter'} use {'romgrk/nvim-treesitter-context', after = 'nvim-treesitter'} use {'nvim-treesitter/nvim-treesitter-textobjects', after = 'nvim-treesitter'} - -- use { - -- 'lewis6991/spellsitter.nvim', - -- event = {'BufRead', 'BufNew', 'BufNewFile'}, - -- config = editor.spellsitter_conf - -- } use { 'lukas-reineke/indent-blankline.nvim', after = 'nvim-treesitter', @@ -137,6 +132,14 @@ return packer.startup(function(use) }, config = editor.eft_conf } + use { + 'monaqa/dial.nvim', + keys = { + {'n', ''}, {'v', ''}, {'v', 'g'}, + {'n', ''}, {'v', ''}, {'v', 'g'} + }, + config = editor.dial_conf + } use {'junegunn/vim-easy-align', cmd = 'EasyAlign'} use { 'terrortylor/nvim-comment', @@ -433,9 +436,9 @@ return packer.startup(function(use) } use {'dstein64/vim-startuptime', cmd = 'StartupTime'} -- Just for benchmarking - -- TODO: dial.nvim, rust-tools.nvim, crates.nvim, go.nvim, clojure-vim/*, - -- nvim-bqf, nvim-comment-frame, nvim-revJ.lua, nvim-remote-containers, - -- tex.nvim, telescope-lsp-handlers.nvim, telescope-dap.nvim + -- TODO: rust-tools.nvim, crates.nvim, go.nvim, clojure-vim/*, nvim-bqf, + -- nvim-comment-frame, nvim-revJ.lua, nvim-remote-containers, tex.nvim, + -- telescope-lsp-handlers.nvim, telescope-dap.nvim -- Install plugins if missing packer.install() diff --git a/home/.config/nvim/scripts/hadolint b/home/.config/nvim/scripts/hadolint new file mode 100755 index 0000000..6b44522 --- /dev/null +++ b/home/.config/nvim/scripts/hadolint @@ -0,0 +1,4 @@ +#!/bin/sh + +podman run --rm -i docker.io/hadolint/hadolint \ + hadolint --no-fail --format=json - < "$@" diff --git a/home/.config/nvim/scripts/lint/hadolint b/home/.config/nvim/scripts/lint/hadolint new file mode 100755 index 0000000..4236a12 --- /dev/null +++ b/home/.config/nvim/scripts/lint/hadolint @@ -0,0 +1,3 @@ +#!/bin/sh + +podman pull docker.io/hadolint/hadolint:latest