style: format lua with StyLua

This commit is contained in:
Oliver Davies 2022-01-09 00:07:35 +00:00
parent f1171dbfc0
commit 5ff925c80c
21 changed files with 200 additions and 194 deletions

View file

@ -19,34 +19,29 @@ local snippets = {}
-- Snippets for both JavaScript and TypeScript. -- Snippets for both JavaScript and TypeScript.
local js_ts = { local js_ts = {
s( s({ trig = "log", dscr = "console.log" }, { t "console.log(", i(1, "value"), t ");" }),
{ trig = 'log', dscr = 'console.log' },
{ t('console.log('), i(1, 'value'), t(');') }
),
} }
snippets.js = js_ts snippets.js = js_ts
snippets.markdown = { snippets.markdown = {
s( s(
{ trig = 'frontmatter', dscr = 'Document frontmatter' }, { trig = "frontmatter", dscr = "Document frontmatter" },
{ t({'---', 'tags: '}), i(1, 'value'), t({'', '---', ''}), i(0) } { t { "---", "tags: " }, i(1, "value"), t { "", "---", "" }, i(0) }
) ),
} }
snippets.php = { snippets.php = {
s( s({ trig = "test", dscr = "Test block" }, {
{ trig = 'test', dscr = 'Test block' }, t { "/* @test **/", "" },
{ t "public function ",
t({ "/* @test **/", "" }), c(1, { t "test", t "it", t "should" }), -- The test method name prefix.
t("public function "), i(2), -- The test method name.
c(1, { t "test", t "it", t "should" }), -- The test method name prefix. t { "(): void {", "" },
i(2), -- The test method name. t " ",
t({ "(): void {", "" }), i(0), -- The method body.
t(" "), i(0), -- The method body. t { "", "}" },
t({ "", "}" }) }),
}
),
} }
snippets.typescript = js_ts snippets.typescript = js_ts

View file

@ -5,14 +5,14 @@ end
zen_mode.setup { zen_mode.setup {
window = { window = {
backdrop = .95, backdrop = 0.95,
height = 1, height = 1,
width = 120, width = 120,
options = { options = {
relativenumber = false, relativenumber = false,
number = false, number = false,
signcolumn = "no", signcolumn = "no",
} },
}, },
plugins = { plugins = {
options = { options = {
@ -21,5 +21,5 @@ zen_mode.setup {
}, },
gitsigns = { enabled = true }, gitsigns = { enabled = true },
tmux = { enabled = true }, tmux = { enabled = true },
} },
} }

View file

@ -1,14 +1,14 @@
require("opdavies.autopairs") require "opdavies.autopairs"
require("opdavies.colours") require "opdavies.colours"
require("opdavies.comment") require "opdavies.comment"
require("opdavies.completion") require "opdavies.completion"
require("opdavies.floaterm") require "opdavies.floaterm"
require("opdavies.gitsigns") require "opdavies.gitsigns"
require("opdavies.indent-blankline") require "opdavies.indent-blankline"
require("opdavies.lsp") require "opdavies.lsp"
require("opdavies.options").setup() require("opdavies.options").setup()
require("opdavies.plugins") require "opdavies.plugins"
require("opdavies.seiya") require "opdavies.seiya"
require("opdavies.telescope") require "opdavies.telescope"
require("opdavies.treesitter") require "opdavies.treesitter"
require("opdavies.vim-test") require "opdavies.vim-test"

View file

@ -10,7 +10,10 @@ if not cmp_status_ok then
return return
end end
local cmp = require('cmp') local cmp = require "cmp"
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({ cmp.event:on(
map_char = { tex = '' } "confirm_done",
})) cmp_autopairs.on_confirm_done {
map_char = { tex = "" },
}
)

View file

@ -8,6 +8,6 @@ if not colorizer_status_ok then
return return
end end
colorbuddy.colorscheme("gruvbuddy") colorbuddy.colorscheme "gruvbuddy"
colorizer.setup() colorizer.setup()

View file

@ -7,8 +7,8 @@ comment.setup {
padding = true, padding = true,
opleader = { opleader = {
line = 'gc', line = "gc",
block = 'gb', block = "gb",
}, },
mappings = { mappings = {

View file

@ -14,7 +14,7 @@ cmp.setup {
snippet = { snippet = {
expand = function(args) expand = function(args)
luasnip.lsp_expand(args.body) luasnip.lsp_expand(args.body)
end end,
}, },
mapping = { mapping = {
@ -44,17 +44,20 @@ cmp.setup {
}, },
formatting = { formatting = {
format = require("lspkind").cmp_format({with_text = true, menu = ({ format = require("lspkind").cmp_format {
buffer = "[buf]", with_text = true,
cmp_tabnine = "[tn]", menu = {
luasnip = "[snip]", buffer = "[buf]",
nvim_lsp = "[lsp]", cmp_tabnine = "[tn]",
nvim_lua = "[lua]", luasnip = "[snip]",
path = "[path]", nvim_lsp = "[lsp]",
})}), nvim_lua = "[lua]",
path = "[path]",
},
},
}, },
experimental = { experimental = {
ghost_text = true ghost_text = true,
}, },
} }

View file

@ -2,7 +2,7 @@ local map = vim.api.nvim_set_keymap
local options = { noremap = true } local options = { noremap = true }
map('n', '<leader>ld', '<cmd>FloatermNew --autoclose=2 --height=0.9 --width=0.9 lazydocker<cr>', options) map("n", "<leader>ld", "<cmd>FloatermNew --autoclose=2 --height=0.9 --width=0.9 lazydocker<cr>", options)
map('n', '<leader>lg', '<cmd>FloatermNew --autoclose=2 --height=0.9 --width=0.9 lazygit<cr>', options) map("n", "<leader>lg", "<cmd>FloatermNew --autoclose=2 --height=0.9 --width=0.9 lazygit<cr>", options)
map('n', '<leader>nn', '<cmd>FloatermNew --autoclose=2 --height=0.5 --width=0.5 nnn -Hde<cr>', options) map("n", "<leader>nn", "<cmd>FloatermNew --autoclose=2 --height=0.5 --width=0.5 nnn -Hde<cr>", options)
map('n', '<leader>tt', '<cmd>FloatermNew --autoclose=2 --height=0.9 --width=0.9 zsh<cr>', options) map("n", "<leader>tt", "<cmd>FloatermNew --autoclose=2 --height=0.9 --width=0.9 zsh<cr>", options)

View file

@ -12,7 +12,7 @@ M.setup = function()
source = "always", source = "always",
header = "", header = "",
prefix = "", prefix = "",
} },
} }
vim.diagnostic.config(config) vim.diagnostic.config(config)
@ -39,7 +39,8 @@ local function lsp_keymaps(--[[ bufnr ]])
end end
M.on_attach = function(--[[ bufnr ]]) M.on_attach = function(--[[ bufnr ]])
lsp_keymaps(--[[ bufnr ]]) lsp_keymaps(--[[ bufnr ]]
)
end end
M.capabilities = cmp_nvim_lsp.update_capabilities(capabilities) M.capabilities = cmp_nvim_lsp.update_capabilities(capabilities)

View file

@ -22,19 +22,17 @@ for _, lsp in ipairs(servers) do
lspconfig[lsp].setup(opts) lspconfig[lsp].setup(opts)
end end
local intelephense_opts = require("opdavies.lsp.settings.intelephense") local intelephense_opts = require "opdavies.lsp.settings.intelephense"
lspconfig.intelephense.setup { lspconfig.intelephense.setup {
vim.tbl_deep_extend("force", intelephense_opts, opts) vim.tbl_deep_extend("force", intelephense_opts, opts),
} }
local sumneko_lua_opts = require("opdavies.lsp.settings.sumneko_lua") local sumneko_lua_opts = require "opdavies.lsp.settings.sumneko_lua"
lspconfig.sumneko_lua.setup( lspconfig.sumneko_lua.setup(vim.tbl_deep_extend("force", sumneko_lua_opts, opts))
vim.tbl_deep_extend("force", sumneko_lua_opts, opts)
)
local tailwindcss_opts = require("opdavies.lsp.settings.tailwindcss") local tailwindcss_opts = require "opdavies.lsp.settings.tailwindcss"
lspconfig.tailwindcss.setup { lspconfig.tailwindcss.setup {
vim.tbl_deep_extend("force", tailwindcss_opts, opts) vim.tbl_deep_extend("force", tailwindcss_opts, opts),
} }
require("opdavies.lsp.handlers").setup() require("opdavies.lsp.handlers").setup()

View file

@ -3,11 +3,11 @@ if not status_ok then
return return
end end
null_ls.setup({ null_ls.setup {
sources = { sources = {
null_ls.builtins.formatting.prettier, null_ls.builtins.formatting.prettier,
null_ls.builtins.formatting.stylua, null_ls.builtins.formatting.stylua,
null_ls.builtins.diagnostics.eslint, null_ls.builtins.diagnostics.eslint,
null_ls.builtins.completion.spell, null_ls.builtins.completion.spell,
}, },
}) }

View file

@ -1,3 +1,3 @@
return { return {
filetypes = { "php", "module", "test", "inc" } filetypes = { "php", "module", "test", "inc" },
} }

View file

@ -2,14 +2,14 @@ return {
settings = { settings = {
Lua = { Lua = {
diagnostics = { diagnostics = {
globals = { "use", "vim" } globals = { "use", "vim" },
}, },
workspace = { workspace = {
library = { library = {
[vim.fn.expand("$VIMRUNTIME/lua")] = true, [vim.fn.expand "$VIMRUNTIME/lua"] = true,
[vim.fn.stdpath("config") .. "/lua"] = true, [vim.fn.stdpath "config" .. "/lua"] = true,
},
}, },
},
}, },
}, },
} }

View file

@ -1,3 +1,3 @@
return { return {
filetypes = { "html", "html.twig", "lua" } filetypes = { "html", "html.twig", "lua" },
} }

View file

@ -1,7 +1,7 @@
local M = {} local M = {}
local function set_autocmd() local function set_autocmd()
vim.cmd[[ vim.cmd [[
autocmd BufRead,BufNewFile *.test set filetype=php autocmd BufRead,BufNewFile *.test set filetype=php
autocmd BufWritePost plugins.lua luafile % autocmd BufWritePost plugins.lua luafile %
@ -15,7 +15,7 @@ local function set_autocmd()
end end
local function set_filetypes() local function set_filetypes()
vim.cmd[[ vim.cmd [[
filetype indent on filetype indent on
filetype on filetype on
filetype plugin on filetype plugin on
@ -27,45 +27,40 @@ local function set_key_mappings()
local options = { noremap = true } local options = { noremap = true }
map('n', '<Leader>so', ':luafile ~/.config/nvim/init.lua<Cr>', options) map("n", "<Leader>so", ":luafile ~/.config/nvim/init.lua<Cr>", options)
-- Format paragraphs to an 80 character line length. -- Format paragraphs to an 80 character line length.
map('n', '<Leader>g', 'gqap', options) map("n", "<Leader>g", "gqap", options)
map('x', '<Leader>g', 'gqa', options) map("x", "<Leader>g", "gqa", options)
-- Make the current file executable -- Make the current file executable
map('n', '<Leader>x', ':!chmod +x %<Cr>', options) map("n", "<Leader>x", ":!chmod +x %<Cr>", options)
-- Yank from the current column to the end of the line -- Yank from the current column to the end of the line
map('n', 'Y', 'yg$', options) map("n", "Y", "yg$", options)
-- Keep things centred -- Keep things centred
map('n', 'n', 'nzzzv', options) map("n", "n", "nzzzv", options)
map('n', 'N', 'Nzzzv', options) map("n", "N", "Nzzzv", options)
-- Remove arrow keys -- Remove arrow keys
map('v', '<down>', '<nop>', options) map("v", "<down>", "<nop>", options)
map('v', '<left>', '<nop>', options) map("v", "<left>", "<nop>", options)
map('v', '<right>', '<nop>', options) map("v", "<right>", "<nop>", options)
map('v', '<up>', '<nop>', options) map("v", "<up>", "<nop>", options)
-- Clears hlsearch after doing a search, otherwise just does normal <CR> stuff -- Clears hlsearch after doing a search, otherwise just does normal <CR> stuff
vim.cmd[[ nnoremap <expr> <CR> {-> v:hlsearch ? ":nohl\<CR>" : "\<CR>"}() ]] vim.cmd [[ nnoremap <expr> <CR> {-> v:hlsearch ? ":nohl\<CR>" : "\<CR>"}() ]]
map( map("n", "<C-f>", ":silent !tmux neww tmux-sessioniser<CR>", { noremap = true, silent = true })
'n',
'<C-f>',
':silent !tmux neww tmux-sessioniser<CR>',
{ noremap = true, silent = true }
)
end end
local function set_highlights() local function set_highlights()
vim.cmd[[highlight Comment cterm=italic gui=italic]] vim.cmd [[highlight Comment cterm=italic gui=italic]]
end end
local function set_vim_g() local function set_vim_g()
vim.g.mapleader = ' ' vim.g.mapleader = " "
end end
local function set_vim_o() local function set_vim_o()
@ -76,10 +71,10 @@ local function set_vim_o()
expandtab = true, expandtab = true,
foldlevel = 1, foldlevel = 1,
foldlevelstart = 1, foldlevelstart = 1,
foldmethod = 'indent', foldmethod = "indent",
formatoptions = 'lm', formatoptions = "lm",
linebreak = true, linebreak = true,
mouse = 'n', mouse = "n",
number = true, number = true,
pumblend = 10, pumblend = 10,
pumheight = 10, pumheight = 10,
@ -92,7 +87,7 @@ local function set_vim_o()
splitbelow = true, splitbelow = true,
splitright = true, splitright = true,
swapfile = false, swapfile = false,
syntax = 'on', syntax = "on",
tabstop = 2, tabstop = 2,
termguicolors = true, termguicolors = true,
textwidth = 0, textwidth = 0,
@ -104,7 +99,7 @@ local function set_vim_o()
vim.o[key] = value vim.o[key] = value
end end
vim.opt.clipboard:append 'unnamedplus' vim.opt.clipboard:append "unnamedplus"
end end
M.setup = function() M.setup = function()

View file

@ -6,81 +6,81 @@ end
packer.init { packer.init {
display = { display = {
open_fn = function() open_fn = function()
return require'packer.util'.float {} return require("packer.util").float {}
end, end,
}, },
} }
return packer.startup(function() return packer.startup(function()
use 'wbthomason/packer.nvim' use "wbthomason/packer.nvim"
-- Utilities -- Utilities
use 'cakebaker/scss-syntax.vim' use "cakebaker/scss-syntax.vim"
use 'christoomey/vim-sort-motion' use "christoomey/vim-sort-motion"
use 'christoomey/vim-tmux-navigator' use "christoomey/vim-tmux-navigator"
use 'editorconfig/editorconfig-vim' use "editorconfig/editorconfig-vim"
use 'folke/twilight.nvim' use "folke/twilight.nvim"
use 'folke/zen-mode.nvim' use "folke/zen-mode.nvim"
use 'icatalina/vim-case-change' use "icatalina/vim-case-change"
use 'kyazdani42/nvim-web-devicons' use "kyazdani42/nvim-web-devicons"
use 'lewis6991/gitsigns.nvim' use "lewis6991/gitsigns.nvim"
use 'lukas-reineke/indent-blankline.nvim' use "lukas-reineke/indent-blankline.nvim"
use 'machakann/vim-highlightedyank' use "machakann/vim-highlightedyank"
use 'miyakogi/seiya.vim' use "miyakogi/seiya.vim"
use 'norcalli/nvim-colorizer.lua' use "norcalli/nvim-colorizer.lua"
use 'numToStr/Comment.nvim' use "numToStr/Comment.nvim"
use 'nvim-lua/plenary.nvim' use "nvim-lua/plenary.nvim"
use 'nvim-lua/popup.nvim' use "nvim-lua/popup.nvim"
use 'sheerun/vim-polyglot' use "sheerun/vim-polyglot"
use 'tpope/vim-surround' use "tpope/vim-surround"
use 'vim-test/vim-test' use "vim-test/vim-test"
use 'voldikss/vim-floaterm' use "voldikss/vim-floaterm"
use 'windwp/nvim-autopairs' use "windwp/nvim-autopairs"
use { 'mg979/vim-visual-multi', branch = 'master' } use { "mg979/vim-visual-multi", branch = "master" }
-- Themes -- Themes
use { use {
'tjdevries/gruvbuddy.nvim', "tjdevries/gruvbuddy.nvim",
requires = { requires = {
'tjdevries/colorbuddy.vim' "tjdevries/colorbuddy.vim",
}, },
} }
-- Navigation -- Navigation
use 'ThePrimeagen/harpoon' use "ThePrimeagen/harpoon"
-- Treesitter -- Treesitter
use { use {
'nvim-treesitter/nvim-treesitter', "nvim-treesitter/nvim-treesitter",
run = ':TSUpdate', run = ":TSUpdate",
} }
-- Completion -- Completion
use { use {
'hrsh7th/nvim-cmp', "hrsh7th/nvim-cmp",
requires = { requires = {
'L3MON4D3/LuaSnip', "L3MON4D3/LuaSnip",
'hrsh7th/cmp-buffer', "hrsh7th/cmp-buffer",
'hrsh7th/cmp-nvim-lsp', "hrsh7th/cmp-nvim-lsp",
'hrsh7th/cmp-path', "hrsh7th/cmp-path",
'onsails/lspkind-nvim', "onsails/lspkind-nvim",
'saadparwaiz1/cmp_luasnip', "saadparwaiz1/cmp_luasnip",
{ {
'tzachar/cmp-tabnine', "tzachar/cmp-tabnine",
run = './install.sh' run = "./install.sh",
} },
} },
} }
-- Snippets -- Snippets
use 'L3MON4D3/LuaSnip' use "L3MON4D3/LuaSnip"
use 'rafamadriz/friendly-snippets' use "rafamadriz/friendly-snippets"
-- LSP -- LSP
use 'neovim/nvim-lspconfig' use "neovim/nvim-lspconfig"
use 'jose-elias-alvarez/null-ls.nvim' use "jose-elias-alvarez/null-ls.nvim"
-- Telescope -- Telescope
use 'nvim-telescope/telescope.nvim' use "nvim-telescope/telescope.nvim"
use { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' } use { "nvim-telescope/telescope-fzf-native.nvim", run = "make" }
end) end)

View file

@ -1,3 +1,3 @@
vim.g.seiya_auto_enable = 1 vim.g.seiya_auto_enable = 1
vim.g.seiya_target_groups = { 'guibg' } vim.g.seiya_target_groups = { "guibg" }

View file

@ -3,38 +3,39 @@ if not status_ok then
return return
end end
local previewers = require('telescope.previewers') local previewers = require "telescope.previewers"
local Job = require('plenary.job') local Job = require "plenary.job"
-- Create a new maker that won't preview binary files -- Create a new maker that won't preview binary files
-- https://github.com/nvim-telescope/telescope.nvim/wiki/Configuration-Recipes#dont-preview-binaries -- https://github.com/nvim-telescope/telescope.nvim/wiki/Configuration-Recipes#dont-preview-binaries
local new_maker = function(filepath, bufnr, opts) local new_maker = function(filepath, bufnr, opts)
filepath = vim.fn.expand(filepath) filepath = vim.fn.expand(filepath)
Job:new({ Job
command = 'file', :new({
args = { '--mime-type', '-b', filepath }, command = "file",
on_exit = function(j) args = { "--mime-type", "-b", filepath },
local mime_type = vim.split(j:result()[1], '/')[1] on_exit = function(j)
if mime_type == "text" then local mime_type = vim.split(j:result()[1], "/")[1]
previewers.buffer_previewer_maker(filepath, bufnr, opts) if mime_type == "text" then
else previewers.buffer_previewer_maker(filepath, bufnr, opts)
vim.schedule(function() else
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, { 'BINARY' }) vim.schedule(function()
end) vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, { "BINARY" })
end end)
end end
}):sync() end,
})
:sync()
end end
telescope.setup{ telescope.setup {
defaults = { defaults = {
buffer_previewer_maker = new_maker, buffer_previewer_maker = new_maker,
prompt_prefix = "$ " prompt_prefix = "$ ",
} },
} }
telescope.load_extension "fzf"
telescope.load_extension("fzf")
local map = vim.api.nvim_set_keymap local map = vim.api.nvim_set_keymap
local options = { local options = {
@ -43,15 +44,20 @@ local options = {
} }
-- Builtin -- Builtin
map('n', '<leader>fb', '<CMD>lua require("telescope.builtin").buffers()<CR>', options) map("n", "<leader>fb", '<CMD>lua require("telescope.builtin").buffers()<CR>', options)
map('n', '<leader>fc', '<CMD>lua require("telescope.builtin").lsp_code_actions()<CR>', options) map("n", "<leader>fc", '<CMD>lua require("telescope.builtin").lsp_code_actions()<CR>', options)
map('n', '<leader>fd', '<CMD>lua require("telescope.builtin").lsp_workspace_diagnostics()<CR>', options) map("n", "<leader>fd", '<CMD>lua require("telescope.builtin").lsp_workspace_diagnostics()<CR>', options)
map('n', '<leader>fe', '<CMD>lua require("telescope.builtin").file_browser{ cwd = vim.fn.expand("%:p:h") }<CR>', options) map(
map('n', '<leader>fg', '<CMD>lua require("telescope.builtin").git_files{}<CR>', options) "n",
map('n', '<leader>fh', '<CMD>lua require("telescope.builtin").help_tags()<CR>', options) "<leader>fe",
map('n', '<leader>fl', '<CMD>lua require("telescope.builtin").live_grep()<CR>', options) '<CMD>lua require("telescope.builtin").file_browser{ cwd = vim.fn.expand("%:p:h") }<CR>',
map('n', '<leader>fr', '<CMD>lua require("telescope.builtin").registers()<CR>', options) options
map('n', '<leader>fr', '<CMD>lua require("telescope.builtin").registers()<CR>', options) )
map("n", "<leader>fg", '<CMD>lua require("telescope.builtin").git_files{}<CR>', options)
map("n", "<leader>fh", '<CMD>lua require("telescope.builtin").help_tags()<CR>', options)
map("n", "<leader>fl", '<CMD>lua require("telescope.builtin").live_grep()<CR>', options)
map("n", "<leader>fr", '<CMD>lua require("telescope.builtin").registers()<CR>', options)
map("n", "<leader>fr", '<CMD>lua require("telescope.builtin").registers()<CR>', options)
-- Custom -- Custom
map("n", "<Leader>en", '<CMD>lua require("opdavies.telescope.mappings").edit_neovim()<Cr>', options) map("n", "<Leader>en", '<CMD>lua require("opdavies.telescope.mappings").edit_neovim()<Cr>', options)

View file

@ -5,7 +5,7 @@ end
configs.setup { configs.setup {
context_commenting = { context_commenting = {
enable = true enable = true,
}, },
ensure_installed = "maintained", ensure_installed = "maintained",
highlight = { highlight = {
@ -14,5 +14,5 @@ configs.setup {
indent = { indent = {
disable = { "yaml" }, disable = { "yaml" },
enable = true, enable = true,
} },
} }

View file

@ -1,13 +1,13 @@
local map = vim.api.nvim_set_keymap local map = vim.api.nvim_set_keymap
local options = { local options = {
silent = true silent = true,
} }
map('n', 't<C-f>', ':TestFile<CR>', options) map("n", "t<C-f>", ":TestFile<CR>", options)
map('n', 't<C-g>', ':TestVisit<CR>', options) map("n", "t<C-g>", ":TestVisit<CR>", options)
map('n', 't<C-l>', ':TestLast<CR>', options) map("n", "t<C-l>", ":TestLast<CR>", options)
map('n', 't<C-n>', ':TestNearest<CR>', options) map("n", "t<C-n>", ":TestNearest<CR>", options)
map('n', 't<C-s>', ':TestSuite<CR>', options) map("n", "t<C-s>", ":TestSuite<CR>", options)
vim.g['test#strategy'] = "neovim" vim.g["test#strategy"] = "neovim"

5
stylua.toml Normal file
View file

@ -0,0 +1,5 @@
indent_type = "Spaces"
indent_width = 2
line_endings = "Unix"
no_call_parentheses = true
quote_style = "AutoPreferDouble"