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.
local js_ts = {
s(
{ trig = 'log', dscr = 'console.log' },
{ t('console.log('), i(1, 'value'), t(');') }
),
s({ trig = "log", dscr = "console.log" }, { t "console.log(", i(1, "value"), t ");" }),
}
snippets.js = js_ts
snippets.markdown = {
s(
{ trig = 'frontmatter', dscr = 'Document frontmatter' },
{ t({'---', 'tags: '}), i(1, 'value'), t({'', '---', ''}), i(0) }
)
{ trig = "frontmatter", dscr = "Document frontmatter" },
{ t { "---", "tags: " }, i(1, "value"), t { "", "---", "" }, i(0) }
),
}
snippets.php = {
s(
{ trig = 'test', dscr = 'Test block' },
{
t({ "/* @test **/", "" }),
t("public function "),
s({ trig = "test", dscr = "Test block" }, {
t { "/* @test **/", "" },
t "public function ",
c(1, { t "test", t "it", t "should" }), -- The test method name prefix.
i(2), -- The test method name.
t({ "(): void {", "" }),
t(" "), i(0), -- The method body.
t({ "", "}" })
}
),
t { "(): void {", "" },
t " ",
i(0), -- The method body.
t { "", "}" },
}),
}
snippets.typescript = js_ts

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -2,7 +2,7 @@ local map = vim.api.nvim_set_keymap
local options = { noremap = true }
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>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>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>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)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,7 +1,7 @@
local M = {}
local function set_autocmd()
vim.cmd[[
vim.cmd [[
autocmd BufRead,BufNewFile *.test set filetype=php
autocmd BufWritePost plugins.lua luafile %
@ -15,7 +15,7 @@ local function set_autocmd()
end
local function set_filetypes()
vim.cmd[[
vim.cmd [[
filetype indent on
filetype on
filetype plugin on
@ -27,45 +27,40 @@ local function set_key_mappings()
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.
map('n', '<Leader>g', 'gqap', options)
map('x', '<Leader>g', 'gqa', options)
map("n", "<Leader>g", "gqap", options)
map("x", "<Leader>g", "gqa", options)
-- 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
map('n', 'Y', 'yg$', options)
map("n", "Y", "yg$", options)
-- 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
map('v', '<down>', '<nop>', options)
map('v', '<left>', '<nop>', options)
map('v', '<right>', '<nop>', options)
map('v', '<up>', '<nop>', options)
map("v", "<down>", "<nop>", options)
map("v", "<left>", "<nop>", options)
map("v", "<right>", "<nop>", options)
map("v", "<up>", "<nop>", options)
-- 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(
'n',
'<C-f>',
':silent !tmux neww tmux-sessioniser<CR>',
{ noremap = true, silent = true }
)
map("n", "<C-f>", ":silent !tmux neww tmux-sessioniser<CR>", { noremap = true, silent = true })
end
local function set_highlights()
vim.cmd[[highlight Comment cterm=italic gui=italic]]
vim.cmd [[highlight Comment cterm=italic gui=italic]]
end
local function set_vim_g()
vim.g.mapleader = ' '
vim.g.mapleader = " "
end
local function set_vim_o()
@ -76,10 +71,10 @@ local function set_vim_o()
expandtab = true,
foldlevel = 1,
foldlevelstart = 1,
foldmethod = 'indent',
formatoptions = 'lm',
foldmethod = "indent",
formatoptions = "lm",
linebreak = true,
mouse = 'n',
mouse = "n",
number = true,
pumblend = 10,
pumheight = 10,
@ -92,7 +87,7 @@ local function set_vim_o()
splitbelow = true,
splitright = true,
swapfile = false,
syntax = 'on',
syntax = "on",
tabstop = 2,
termguicolors = true,
textwidth = 0,
@ -104,7 +99,7 @@ local function set_vim_o()
vim.o[key] = value
end
vim.opt.clipboard:append 'unnamedplus'
vim.opt.clipboard:append "unnamedplus"
end
M.setup = function()

View file

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

View file

@ -1,3 +1,3 @@
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
end
local previewers = require('telescope.previewers')
local Job = require('plenary.job')
local previewers = require "telescope.previewers"
local Job = require "plenary.job"
-- Create a new maker that won't preview binary files
-- https://github.com/nvim-telescope/telescope.nvim/wiki/Configuration-Recipes#dont-preview-binaries
local new_maker = function(filepath, bufnr, opts)
filepath = vim.fn.expand(filepath)
Job:new({
command = 'file',
args = { '--mime-type', '-b', filepath },
Job
:new({
command = "file",
args = { "--mime-type", "-b", filepath },
on_exit = function(j)
local mime_type = vim.split(j:result()[1], '/')[1]
local mime_type = vim.split(j:result()[1], "/")[1]
if mime_type == "text" then
previewers.buffer_previewer_maker(filepath, bufnr, opts)
else
vim.schedule(function()
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, { 'BINARY' })
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, { "BINARY" })
end)
end
end
}):sync()
end,
})
:sync()
end
telescope.setup{
telescope.setup {
defaults = {
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 options = {
@ -43,15 +44,20 @@ local options = {
}
-- Builtin
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>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('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)
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>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("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
map("n", "<Leader>en", '<CMD>lua require("opdavies.telescope.mappings").edit_neovim()<Cr>', options)

View file

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

View file

@ -1,13 +1,13 @@
local map = vim.api.nvim_set_keymap
local options = {
silent = true
silent = true,
}
map('n', 't<C-f>', ':TestFile<CR>', options)
map('n', 't<C-g>', ':TestVisit<CR>', options)
map('n', 't<C-l>', ':TestLast<CR>', options)
map('n', 't<C-n>', ':TestNearest<CR>', options)
map('n', 't<C-s>', ':TestSuite<CR>', options)
map("n", "t<C-f>", ":TestFile<CR>", options)
map("n", "t<C-g>", ":TestVisit<CR>", options)
map("n", "t<C-l>", ":TestLast<CR>", options)
map("n", "t<C-n>", ":TestNearest<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"