Skip to content

Commit

Permalink
style(lua): lint/format all files with same settings
Browse files Browse the repository at this point in the history
  • Loading branch information
silveiralexf committed Jul 29, 2024
1 parent f8ede27 commit 14d0a10
Show file tree
Hide file tree
Showing 61 changed files with 1,369 additions and 1,374 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@


### [2024-07-29]
* [[f8ede27]](https://github.com/silveiralexf/.dotfiles/commit/f8ede278af5655f1ca1fb7067cdf5594d7e58679) feat: add hammerspoon (silveiralexf@gmail.com)


* [[ec5c3ae]](https://github.com/silveiralexf/.dotfiles/commit/ec5c3ae76505b928794f9e35e6984d5d95a89d6e) chore(lua): consolidate lint and editor configs (silveiralexf@gmail.com)


Expand Down
2 changes: 1 addition & 1 deletion nvim/init.lua
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
-- bootstrap lazy.nvim, LazyVim and your plugins
require("config.lazy")
require('config.lazy')
92 changes: 46 additions & 46 deletions nvim/lua/config/autocmds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,43 @@

vim.cmd([[highlight ColorColumn guibg=#FF8C00]])

vim.api.nvim_create_autocmd("FileType", {
pattern = { "neo-tree", "Outline" },
vim.api.nvim_create_autocmd('FileType', {
pattern = { 'neo-tree', 'Outline' },
callback = function()
-- require('ufo').detach()
vim.opt_local.foldenable = false
end,
})

-- Always attach LSP when available
vim.api.nvim_create_autocmd("LspAttach", {
vim.api.nvim_create_autocmd('LspAttach', {
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
if client and client.supports_method("textDocument/implementation") then
vim.keymap.set("n", "K", vim.lsp.buf.hover, { buffer = 0 })
vim.keymap.set("n", "gd", vim.lsp.buf.definition, {
if client and client.supports_method('textDocument/implementation') then
vim.keymap.set('n', 'K', vim.lsp.buf.hover, { buffer = 0 })
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, {
buffer = 0,
desc = "Go to definition",
desc = 'Go to definition',
})
end
end,
})

vim.lsp.start_client({
name = "terraformls",
cmd = { "terraform-ls", "serve" },
root_dir = vim.fs.dirname(vim.fs.find({ "*.hcl", "*.tf" }, { upward = true })[1]),
name = 'terraformls',
cmd = { 'terraform-ls', 'serve' },
root_dir = vim.fs.dirname(vim.fs.find({ '*.hcl', '*.tf' }, { upward = true })[1]),
})

-- Create an event handler for Tiltfiles
vim.api.nvim_create_autocmd("FileType", {
pattern = "bzl",
vim.api.nvim_create_autocmd('FileType', {
pattern = 'bzl',
callback = function(ev)
vim.lsp.start({
name = "bzl",
root_dir = vim.fs.root(ev.buf, { "Tiltfile", "bzl" }),
name = 'bzl',
root_dir = vim.fs.root(ev.buf, { 'Tiltfile', 'bzl' }),
codelens = { enable = true },
cmd = { "tilt", "lsp", "start" },
cmd = { 'tilt', 'lsp', 'start' },
docs = {
description = [[
https://docs.stack.build/docs/cli/installation
Expand All @@ -53,30 +53,30 @@ https://docs.stack.build/docs/vscode/starlark-language-server
end,
})

vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
pattern = { "*.gohtml", "*.go.html" },
vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, {
pattern = { '*.gohtml', '*.go.html' },
callback = function()
vim.opt_local.filetype = "gohtmltmpl"
vim.opt_local.filetype = 'gohtmltmpl'
end,
})
vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
pattern = { "*.gotmpl", "*.go.tmpl", "*.tmpl" },
vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, {
pattern = { '*.gotmpl', '*.go.tmpl', '*.tmpl' },
callback = function()
vim.opt_local.filetype = "gotexttmpl"
vim.opt_local.filetype = 'gotexttmpl'
end,
})

-- Go auto organize imports
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = "*.go",
vim.api.nvim_create_autocmd('BufWritePre', {
pattern = '*.go',
callback = function()
local params = vim.lsp.util.make_range_params()
params.context = { only = { "source.organizeImports" } }
local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params)
params.context = { only = { 'source.organizeImports' } }
local result = vim.lsp.buf_request_sync(0, 'textDocument/codeAction', params)
for cid, res in pairs(result or {}) do
for _, r in pairs(res.result or {}) do
if r.edit then
local enc = (vim.lsp.get_client_by_id(cid) or {}).offset_encoding or "utf-16"
local enc = (vim.lsp.get_client_by_id(cid) or {}).offset_encoding or 'utf-16'
vim.lsp.util.apply_workspace_edit(r.edit, enc)
end
end
Expand All @@ -86,9 +86,9 @@ vim.api.nvim_create_autocmd("BufWritePre", {
})

-- Setup Vue/Volar without conflicting with TypeScript server
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("LspAttachConflicts", { clear = true }),
desc = "Prevent tsserver and volar conflict",
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('LspAttachConflicts', { clear = true }),
desc = 'Prevent tsserver and volar conflict',
callback = function(args)
if not (args.data and args.data.client_id) then
return
Expand All @@ -97,9 +97,9 @@ vim.api.nvim_create_autocmd("LspAttach", {
local active_clients = vim.lsp.get_clients()
local client = vim.lsp.get_client_by_id(args.data.client_id)

if client ~= nil and client.name == "volar" then
if client ~= nil and client.name == 'volar' then
for _, c in ipairs(active_clients) do
if c.name == "tsserver" then
if c.name == 'tsserver' then
c.stop()
end
end
Expand All @@ -109,19 +109,19 @@ vim.api.nvim_create_autocmd("LspAttach", {

-- Markdown preview with Glow
local function render_markdown_with_glow()
local tempfile = vim.fn.tempname() .. ".md"
vim.cmd("write! " .. tempfile)
local tempfile = vim.fn.tempname() .. '.md'
vim.cmd('write! ' .. tempfile)

vim.cmd("enew")
vim.cmd('enew')
local bufnr = vim.api.nvim_get_current_buf()

local command = "terminal glow -p " .. tempfile
local command = 'terminal glow -p ' .. tempfile

vim.cmd(command)

vim.cmd("startinsert!")
vim.cmd('startinsert!')

vim.api.nvim_create_autocmd("TermClose", {
vim.api.nvim_create_autocmd('TermClose', {
buffer = bufnr,
callback = function()
---@diagnostic disable-next-line: undefined-field
Expand All @@ -131,30 +131,30 @@ local function render_markdown_with_glow()
})
end

vim.api.nvim_create_autocmd("FileType", {
pattern = "markdown",
vim.api.nvim_create_autocmd('FileType', {
pattern = 'markdown',
callback = function()
vim.keymap.set("n", "<leader>ug", render_markdown_with_glow, {
vim.keymap.set('n', '<leader>ug', render_markdown_with_glow, {
silent = true,
buffer = true,
desc = "render markdown with glow",
desc = 'render markdown with glow',
})
end,
})

-- Wrap and check for spell in text filetypes.
vim.api.nvim_create_autocmd("FileType", {
group = vim.api.nvim_create_augroup("wrap_spell", { clear = true }),
pattern = { "gitcommit", "markdown" },
vim.api.nvim_create_autocmd('FileType', {
group = vim.api.nvim_create_augroup('wrap_spell', { clear = true }),
pattern = { 'gitcommit', 'markdown' },
callback = function()
vim.opt_local.wrap = true
vim.opt_local.spell = true
end,
})

-- Go to last loc when opening a buffer.
vim.api.nvim_create_autocmd("BufReadPost", {
group = vim.api.nvim_create_augroup("last_loc", { clear = true }),
vim.api.nvim_create_autocmd('BufReadPost', {
group = vim.api.nvim_create_augroup('last_loc', { clear = true }),
callback = function()
local mark = vim.api.nvim_buf_get_mark(0, '"')
local lcount = vim.api.nvim_buf_line_count(0)
Expand Down
46 changes: 23 additions & 23 deletions nvim/lua/config/keymaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,46 @@ local function map(mode, lhs, rhs, opts)
vim.keymap.set(mode, lhs, rhs, opts)
end

map("n", "<leader><tab>v", "<cmd>vnew<cr>", { desc = "New vertically split pane" })
map("n", "<leader>s", "<cmd>TelescopeSearch<cr>", { desc = "TelescopeSearch" })
map("n", "<leader>f", "<cmd>TelescopeFind<cr>", { desc = "TelescopeFind" })
map("n", "<leader>k", "<cmd>WhichKey<cr>", { desc = "Whichkey" })
map("n", "<leader>F", "<cmd>FzfLua<cr>", { desc = "FuzzyLuaFinder" })
map("n", "<leader>t", "<cmd>NeoTest<cr>", { desc = "NeoTest" })
map("n", "<leader>O", "<cmd>Ollama<cr>", { desc = "Ollama" })
map("v", "<leader>O", "<cmd>Ollama<cr>", { desc = "Ollama" })
map("n", "<leader>Oc", "<cmd>Llama<cr>", { desc = "Ollama-Chat" })
map("n", "<leader>o", "<cmd>Obsidian<cr>", { desc = "Obsidian" })
map("n", "<leader>of", "<cmd>ObsidianSearch<cr>", { desc = "ObsidianSearch" })
map("n", "<leader>on", "<cmd>ObsidianNew<cr>", { desc = "ObsidianNew" })
map("n", "<leader>ot", "<cmd>ObsidianTags<cr>", { desc = "ObsidianTags" })
map("n", "<leader>ox", "<cmd>ObsidianExtractNote<cr>", { desc = "ObsidianExtractNote" })
map("n", "<leader>oF", function()
if require("obsidian").util.cursor_on_markdown_link() then
return "<cmd>ObsidianFollowLink<CR>"
map('n', '<leader><tab>v', '<cmd>vnew<cr>', { desc = 'New vertically split pane' })
map('n', '<leader>s', '<cmd>TelescopeSearch<cr>', { desc = 'TelescopeSearch' })
map('n', '<leader>f', '<cmd>TelescopeFind<cr>', { desc = 'TelescopeFind' })
map('n', '<leader>k', '<cmd>WhichKey<cr>', { desc = 'Whichkey' })
map('n', '<leader>F', '<cmd>FzfLua<cr>', { desc = 'FuzzyLuaFinder' })
map('n', '<leader>t', '<cmd>NeoTest<cr>', { desc = 'NeoTest' })
map('n', '<leader>O', '<cmd>Ollama<cr>', { desc = 'Ollama' })
map('v', '<leader>O', '<cmd>Ollama<cr>', { desc = 'Ollama' })
map('n', '<leader>Oc', '<cmd>Llama<cr>', { desc = 'Ollama-Chat' })
map('n', '<leader>o', '<cmd>Obsidian<cr>', { desc = 'Obsidian' })
map('n', '<leader>of', '<cmd>ObsidianSearch<cr>', { desc = 'ObsidianSearch' })
map('n', '<leader>on', '<cmd>ObsidianNew<cr>', { desc = 'ObsidianNew' })
map('n', '<leader>ot', '<cmd>ObsidianTags<cr>', { desc = 'ObsidianTags' })
map('n', '<leader>ox', '<cmd>ObsidianExtractNote<cr>', { desc = 'ObsidianExtractNote' })
map('n', '<leader>oF', function()
if require('obsidian').util.cursor_on_markdown_link() then
return '<cmd>ObsidianFollowLink<CR>'
else
return ""
return ''
end
end, {
noremap = false,
expr = true,
desc = "ObsidianFollowLink",
desc = 'ObsidianFollowLink',
})

--map("n", "<tab>h", "<cmd>tabprev<cr>", { desc = "Previous tab" })
--map("n", "<tab>l", "<cmd>tabnex<cr>", { desc = "Next tab" })
--map("n", "<tab>n", "<cmd>tabnew<cr>", { desc = "New tab" })

map("n", "\\f", "<cmd>Neotree focus<cr>", { desc = "Focus on Neotree" })
map('n', '\\f', '<cmd>Neotree focus<cr>', { desc = 'Focus on Neotree' })

-- map("n", "\\e", function()
-- require("vim.diagnostic").open_float()
-- end, { desc = "Show Diagnostics" })

map("n", "\\w", function()
local wp = require("window-picker")
map('n', '\\w', function()
local wp = require('window-picker')
local picked_window_id = wp.pick_window() or vim.api.nvim_get_current_win()
vim.api.nvim_set_current_win(picked_window_id)
end, { desc = "Pick window" })
end, { desc = 'Pick window' })

-- EOF
80 changes: 40 additions & 40 deletions nvim/lua/config/lazy.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
--- @diagnostic disable-next-line: undefined-field
if not vim.loop.fs_stat(lazypath) then
-- bootstrap lazy.nvim
Expand All @@ -12,24 +12,24 @@ if not vim.loop.fs_stat(lazypath) then
end

vim.opt.rtp:prepend(vim.env.LAZY or lazypath)
require("lazy").setup({
require('lazy').setup({
spec = {
-- add LazyVim and import its plugins
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
{ 'LazyVim/LazyVim', import = 'lazyvim.plugins' },
-- import any extras modules here
{ import = "lazyvim.plugins.extras.lang.docker" },
{ import = "lazyvim.plugins.extras.lang.go" },
{ import = "lazyvim.plugins.extras.lang.helm" },
{ import = "lazyvim.plugins.extras.lang.json" },
{ import = "lazyvim.plugins.extras.lang.rust" },
{ import = "lazyvim.plugins.extras.lang.typescript" },
{ import = "lazyvim.plugins.extras.linting.eslint" },
{ import = "lazyvim.plugins.extras.ui.mini-animate" },
{ import = "lazyvim.plugins.extras.vscode" },
{ import = "lazyvim.plugins.extras.dap.core" },
{ import = 'lazyvim.plugins.extras.lang.docker' },
{ import = 'lazyvim.plugins.extras.lang.go' },
{ import = 'lazyvim.plugins.extras.lang.helm' },
{ import = 'lazyvim.plugins.extras.lang.json' },
{ import = 'lazyvim.plugins.extras.lang.rust' },
{ import = 'lazyvim.plugins.extras.lang.typescript' },
{ import = 'lazyvim.plugins.extras.linting.eslint' },
{ import = 'lazyvim.plugins.extras.ui.mini-animate' },
{ import = 'lazyvim.plugins.extras.vscode' },
{ import = 'lazyvim.plugins.extras.dap.core' },
-- import/override with your plugins
{ import = "plugins" },
{ import = "lsp" },
{ import = 'plugins' },
{ import = 'lsp' },
},
defaults = {
-- By default, only LazyVim plugins will be lazy-loaded. Your custom
Expand All @@ -44,39 +44,39 @@ require("lazy").setup({
-- version = "*", -- try installing the latest stable version for plugins
-- that support semver
},
install = { colorscheme = { "tokyonight", "tokyonight-night", "habamax", "gruvbox", "catppuccin" } },
install = { colorscheme = { 'tokyonight', 'tokyonight-night', 'habamax', 'gruvbox', 'catppuccin' } },

ui = {
-- a number <1 is a percentage., >1 is a fixed size
size = { width = 0.8, height = 0.8 },
wrap = false, -- wrap the lines in the ui
-- The border to use for the UI window. Accepts same border values as |nvim_open_win()|.
border = "none",
border = 'none',
-- The backdrop opacity. 0 is fully opaque, 100 is fully transparent.
backdrop = 60,
title = nil, ---@type string only works when border is not "none"
title_pos = "center", ---@type "center" | "left" | "right"
title_pos = 'center', ---@type "center" | "left" | "right"
-- Show pills on top of the Lazy window
pills = true, ---@type boolean
icons = {
cmd = "",
config = "🛠",
event = "📅",
ft = "📂",
init = "",
keys = "🗝",
plugin = "🔌",
runtime = "💻",
require = "🌙",
source = "📄",
start = "🚀",
task = "📌",
lazy = "💤 ",
cmd = '',
config = '🛠',
event = '📅',
ft = '📂',
init = '',
keys = '🗝',
plugin = '🔌',
runtime = '💻',
require = '🌙',
source = '📄',
start = '🚀',
task = '📌',
lazy = '💤 ',
list = {
"",
"",
"",
"",
'',
'',
'',
'',
},
},
},
Expand All @@ -88,11 +88,11 @@ require("lazy").setup({
rtp = {
-- disable some rtp plugins
disabled_plugins = {
"gzip",
"tarPlugin",
"tohtml",
"tutor",
"zipPlugin",
'gzip',
'tarPlugin',
'tohtml',
'tutor',
'zipPlugin',
},
},
},
Expand Down
Loading

0 comments on commit 14d0a10

Please sign in to comment.