Skip to content

Commit ad1eda4

Browse files
committed
format using stylua
1 parent ca972a3 commit ad1eda4

File tree

15 files changed

+389
-402
lines changed

15 files changed

+389
-402
lines changed

init.lua

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
if vim.fn.has('nvim-0.8') == 0 then
2-
error('Need Neovim 0.8+ in order to use this config')
3-
end
1+
if vim.fn.has "nvim-0.8" == 0 then error "Need Neovim 0.8+ in order to use this config" end
42

5-
for _, cmd in ipairs({ "git", "rg", { "fd", "fdfind" } }) do
3+
for _, cmd in ipairs { "git", "rg", { "fd", "fdfind" } } do
64
local name = type(cmd) == "string" and cmd or vim.inspect(cmd)
75
local commands = type(cmd) == "string" and { cmd } or cmd
86
---@cast commands string[]
@@ -15,39 +13,38 @@ for _, cmd in ipairs({ "git", "rg", { "fd", "fdfind" } }) do
1513
end
1614
end
1715

18-
if not found then
19-
error(("`%s` is not installed"):format(name))
20-
end
16+
if not found then error(("`%s` is not installed"):format(name)) end
2117
end
2218

2319
vim.opt.termguicolors = true -- enable 24-bit RGB colors
2420
-- Disable annoying deprecated message
2521
vim.deprecate = function() end
2622

2723
-- bootstrap lazy and all plugins
28-
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
24+
local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim"
2925
if not vim.loop.fs_stat(lazypath) then
30-
vim.fn.system(
31-
{ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", -- latest stable release
32-
lazypath })
26+
vim.fn.system {
27+
"git",
28+
"clone",
29+
"--filter=blob:none",
30+
"https://github.com/folke/lazy.nvim.git",
31+
"--branch=stable", -- latest stable release
32+
lazypath,
33+
}
3334
end
3435
vim.opt.rtp:prepend(lazypath)
3536

3637
-- Load default configurations and plugins
37-
for _, source in ipairs({
38+
for _, source in ipairs {
3839
"plugins",
3940
"options",
4041
"mappings",
41-
"autocmds"
42-
}) do
42+
"autocmds",
43+
} do
4344
local ok, fault = pcall(require, source)
44-
if not ok then
45-
vim.api.nvim_err_writeln("Failed to load " .. source .. "\n\n" .. fault)
46-
end
45+
if not ok then vim.api.nvim_err_writeln("Failed to load " .. source .. "\n\n" .. fault) end
4746
end
4847

4948
-- Load custom configurations
5049
local exist, custom = pcall(require, "custom")
51-
if exist and type(custom) == "table" and custom.configs then
52-
custom.configs()
53-
end
50+
if exist and type(custom) == "table" and custom.configs then custom.configs() end

lua/autocmds.lua

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,47 +18,47 @@ local autocmd = vim.api.nvim_create_autocmd -- Create autocommand
1818
-- Highlight on yank
1919
autocmd("TextYankPost", {
2020
callback = function()
21-
vim.highlight.on_yank({
21+
vim.highlight.on_yank {
2222
higroup = "IncSearch",
23-
timeout = "1000"
24-
})
25-
end
23+
timeout = "1000",
24+
}
25+
end,
2626
})
2727

2828
-- Remove whitespace on save
2929
autocmd("BufWritePre", {
3030
pattern = "",
31-
command = ":%s/\\s\\+$//e"
31+
command = ":%s/\\s\\+$//e",
3232
})
3333

3434
-- Auto format on save using the attached (optionally filtered) language servere clients
3535
-- https://neovim.io/doc/user/lsp.html#vim.lsp.buf.format()
3636
autocmd("BufWritePre", {
3737
pattern = "",
38-
command = ":silent lua vim.lsp.buf.format()"
38+
command = ":silent lua vim.lsp.buf.format()",
3939
})
4040

4141
-- Don"t auto commenting new lines
4242
autocmd("BufEnter", {
4343
pattern = "",
44-
command = "set fo-=c fo-=r fo-=o"
44+
command = "set fo-=c fo-=r fo-=o",
4545
})
4646

4747
autocmd("Filetype", {
4848
pattern = { "xml", "html", "xhtml", "css", "scss", "javascript", "typescript", "yaml", "lua" },
49-
command = "setlocal shiftwidth=2 tabstop=2"
49+
command = "setlocal shiftwidth=2 tabstop=2",
5050
})
5151

5252
-- Set colorcolumn
5353
autocmd("Filetype", {
5454
pattern = { "python", "rst", "c", "cpp" },
55-
command = "set colorcolumn=80"
55+
command = "set colorcolumn=80",
5656
})
5757

5858
autocmd("Filetype", {
5959
pattern = { "gitcommit", "markdown", "text" },
6060
callback = function()
6161
vim.opt_local.wrap = true
6262
vim.opt_local.spell = true
63-
end
63+
end,
6464
})

lua/mappings.lua

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,32 +34,35 @@ map("n", "<leader>wl", "<C-w>l", { desc = "switch window down" })
3434
-- vim.notify("Nvim configuration reloaded!", vim.log.levels.INFO)
3535
-- end
3636
function _G.reload_config()
37-
local reload = require("plenary.reload").reload_module
38-
reload("me", false)
37+
local reload = require("plenary.reload").reload_module
38+
reload("me", false)
3939

40-
dofile(vim.env.MYVIMRC)
41-
vim.notify("Nvim configuration reloaded!", vim.log.levels.INFO)
40+
dofile(vim.env.MYVIMRC)
41+
vim.notify("Nvim configuration reloaded!", vim.log.levels.INFO)
4242
end
4343

4444
map("n", "<leader>rr", _G.reload_config, { desc = "Reload configuration without restart nvim" })
4545

4646
-- Telescope
47-
local builtin = require("telescope.builtin")
47+
local builtin = require "telescope.builtin"
4848
map("n", "<leader>ff", builtin.find_files, { desc = "Open Telescope to find files" })
4949
map("n", "<leader>fg", builtin.live_grep, { desc = "Open Telescope to do live grep" })
5050
map("n", "<leader>fb", builtin.buffers, { desc = "Open Telescope to list buffers" })
5151
map("n", "<leader>fh", builtin.help_tags, { desc = "Open Telescope to show help" })
5252
map("n", "<leader>fo", builtin.oldfiles, { desc = "Open Telescope to list recent files" })
5353
map("n", "<leader>cm", builtin.git_commits, { desc = "Open Telescope to list git commits" })
5454
-- NvimTree
55-
map("n", "<leader>n", ":NvimTreeToggle<CR>", { desc = "Toggle NvimTree sidebar" }) -- open/close
56-
map("n", "<leader>nr", ":NvimTreeRefresh<CR>", { desc = "Refresh NvimTree" }) -- refresh
55+
map("n", "<leader>n", ":NvimTreeToggle<CR>", { desc = "Toggle NvimTree sidebar" }) -- open/close
56+
map("n", "<leader>nr", ":NvimTreeRefresh<CR>", { desc = "Refresh NvimTree" }) -- refresh
5757
map("n", "<leader>nf", ":NvimTreeFindFile<CR>", { desc = "Search file in NvimTree" }) -- search file
5858

5959
-- LSP
60-
map("n", "<leader>gm", function()
61-
require("conform").format { lsp_fallback = true }
62-
end, { desc = "General Format file" })
60+
map(
61+
"n",
62+
"<leader>gm",
63+
function() require("conform").format { lsp_fallback = true } end,
64+
{ desc = "General Format file" }
65+
)
6366

6467
-- global lsp mappings
6568
map("n", "<leader>ds", vim.diagnostic.setloclist, { desc = "LSP Diagnostic loclist" })

lua/options.lua

Lines changed: 73 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -18,79 +18,79 @@ local indent = 4
1818

1919
g.mapleader = " "
2020

21-
cmd([[
21+
cmd [[
2222
filetype plugin indent on
23-
]])
23+
]]
2424

2525
opt.backspace = { "eol", "start", "indent" } -- allow backspacing over everything in insert mode
26-
opt.clipboard = "unnamedplus" -- allow neovim to access the system clipboard
27-
opt.fileencoding = "utf-8" -- the encoding written to a file
28-
opt.encoding = "utf-8" -- the encoding
26+
opt.clipboard = "unnamedplus" -- allow neovim to access the system clipboard
27+
opt.fileencoding = "utf-8" -- the encoding written to a file
28+
opt.encoding = "utf-8" -- the encoding
2929
opt.matchpairs = { "(:)", "{:}", "[:]", "<:>" }
3030
opt.syntax = "enable"
3131

3232
-- indention
33-
opt.autoindent = true -- auto indentation
34-
opt.expandtab = true -- convert tabs to spaces
35-
opt.shiftwidth = indent -- the number of spaces inserted for each indentation
36-
opt.smartindent = true -- make indenting smarter
33+
opt.autoindent = true -- auto indentation
34+
opt.expandtab = true -- convert tabs to spaces
35+
opt.shiftwidth = indent -- the number of spaces inserted for each indentation
36+
opt.smartindent = true -- make indenting smarter
3737
opt.softtabstop = indent -- when hitting <BS>, pretend like a tab is removed, even if spaces
38-
opt.tabstop = indent -- insert 2 spaces for a tab
39-
opt.shiftround = true -- use multiple of shiftwidth when indenting with "<" and ">"
38+
opt.tabstop = indent -- insert 2 spaces for a tab
39+
opt.shiftround = true -- use multiple of shiftwidth when indenting with "<" and ">"
4040

4141
-- tabline
42-
opt.showtabline = 2 -- always show tabs
43-
opt.sessionoptions = 'curdir,folds,globals,help,tabpages,terminal,winsize'
42+
opt.showtabline = 2 -- always show tabs
43+
opt.sessionoptions = "curdir,folds,globals,help,tabpages,terminal,winsize"
4444
-- search
45-
opt.hlsearch = true -- highlight all matches on previous search pattern
45+
opt.hlsearch = true -- highlight all matches on previous search pattern
4646
opt.ignorecase = true -- ignore case in search patterns
47-
opt.smartcase = true -- smart case
47+
opt.smartcase = true -- smart case
4848
opt.wildignore = opt.wildignore + { "*/node_modules/*", "*/.git/*", "*/vendor/*" }
49-
opt.wildmenu = true -- make tab completion for files/buffers act like bash
49+
opt.wildmenu = true -- make tab completion for files/buffers act like bash
5050

5151
-- ui
5252
opt.cursorline = true -- highlight the current line
53-
opt.laststatus = 2 -- only the last window will always have a status line
53+
opt.laststatus = 2 -- only the last window will always have a status line
5454
opt.lazyredraw = true -- don"t update the display while executing macros
5555
opt.list = true
5656
-- You can also add "space" or "eol", but I feel it"s quite annoying
5757
opt.listchars = {
58-
tab = "",
59-
trail = "·",
60-
extends = "»",
61-
precedes = "«",
62-
nbsp = "×"
58+
tab = "",
59+
trail = "·",
60+
extends = "»",
61+
precedes = "«",
62+
nbsp = "×",
6363
}
6464

6565
-- Hide cmd line
66-
opt.cmdheight = 0 -- more space in the neovim command line for displaying messages
66+
opt.cmdheight = 0 -- more space in the neovim command line for displaying messages
6767

68-
opt.mouse = "a" -- allow the mouse to be used in neovim
69-
opt.number = true -- set numbered lines
70-
opt.scrolloff = 18 -- minimal number of screen lines to keep above and below the cursor
71-
opt.sidescrolloff = 3 -- minimal number of screen columns to keep to the left and right (horizontal) of the cursor if wrap is `false`
68+
opt.mouse = "a" -- allow the mouse to be used in neovim
69+
opt.number = true -- set numbered lines
70+
opt.scrolloff = 18 -- minimal number of screen lines to keep above and below the cursor
71+
opt.sidescrolloff = 3 -- minimal number of screen columns to keep to the left and right (horizontal) of the cursor if wrap is `false`
7272
opt.signcolumn = "yes" -- always show the sign column, otherwise it would shift the text each time
73-
opt.splitbelow = true -- open new split below
74-
opt.splitright = true -- open new split to the right
75-
opt.wrap = true -- display a wrapped line
73+
opt.splitbelow = true -- open new split below
74+
opt.splitright = true -- open new split to the right
75+
opt.wrap = true -- display a wrapped line
7676

7777
-- backups
78-
opt.backup = false -- create a backup file
79-
opt.swapfile = false -- creates a swapfile
78+
opt.backup = false -- create a backup file
79+
opt.swapfile = false -- creates a swapfile
8080
opt.writebackup = false -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited
8181

8282
-- autocomplete
8383
opt.completeopt = { "menu", "menuone", "noselect" } -- mostly just for cmp
8484
opt.shortmess = opt.shortmess + {
85-
c = true
85+
c = true,
8686
} -- hide all the completion messages, e.g. "-- XXX completion (YYY)", "match 1 of 2", "The only match", "Pattern not found"
8787

8888
-- By the way, -- INSERT -- is unnecessary anymore because the mode information is displayed in the statusline.
8989
opt.showmode = false
9090

9191
-- perfomance
9292
-- remember N lines in history
93-
opt.history = 100 -- keep 100 lines of history
93+
opt.history = 100 -- keep 100 lines of history
9494
opt.redrawtime = 1500
9595
opt.timeoutlen = 250 -- time to wait for a mapped sequence to complete (in milliseconds)
9696
opt.ttimeoutlen = 10
@@ -101,7 +101,7 @@ opt.termguicolors = true -- enable 24-bit RGB colors
101101

102102
-- persistent undo
103103
-- Don"t forget to create folder $HOME/.local/share/nvim/undo
104-
local undodir = vim.fn.stdpath("data") .. "/undo"
104+
local undodir = vim.fn.stdpath "data" .. "/undo"
105105
opt.undofile = true -- enable persistent undo
106106
opt.undodir = undodir
107107
opt.undolevels = 1000
@@ -113,30 +113,51 @@ opt.foldlevel = 99
113113

114114
-- Disable builtin plugins
115115
local disabled_built_ins = {
116-
"2html_plugin", "getscript", "getscriptPlugin", "gzip", "logipat", "netrw", "netrwPlugin",
117-
"netrwSettings", "netrwFileHandlers", "matchit", "tar", "tarPlugin", "rrhelper",
118-
"spellfile_plugin", "vimball", "vimballPlugin", "zip", "zipPlugin", "tutor", "rplugin",
119-
"synmenu", "optwin", "compiler", "bugreport", "ftplugin"
116+
"2html_plugin",
117+
"getscript",
118+
"getscriptPlugin",
119+
"gzip",
120+
"logipat",
121+
"netrw",
122+
"netrwPlugin",
123+
"netrwSettings",
124+
"netrwFileHandlers",
125+
"matchit",
126+
"tar",
127+
"tarPlugin",
128+
"rrhelper",
129+
"spellfile_plugin",
130+
"vimball",
131+
"vimballPlugin",
132+
"zip",
133+
"zipPlugin",
134+
"tutor",
135+
"rplugin",
136+
"synmenu",
137+
"optwin",
138+
"compiler",
139+
"bugreport",
140+
"ftplugin",
120141
}
121142

122143
for _, plugin in pairs(disabled_built_ins) do
123-
g["loaded_" .. plugin] = 1
144+
g["loaded_" .. plugin] = 1
124145
end
125146

126147
-- Colorscheme
127148
-- By default, use rose-pine
128-
cmd.colorscheme("rose-pine")
149+
cmd.colorscheme "rose-pine"
129150

130151
-- Enable virtual_lines feature if the current nvim version is 0.11+
131-
if vim.fn.has('nvim-0.11') > 0 then
132-
vim.diagnostic.config({
133-
-- Use the default configuration
134-
virtual_lines = true
135-
136-
-- Alternatively, customize specific options
137-
-- virtual_lines = {
138-
-- -- Only show virtual line diagnostics for the current cursor line
139-
-- current_line = true,
140-
-- },
141-
})
152+
if vim.fn.has "nvim-0.11" > 0 then
153+
vim.diagnostic.config {
154+
-- Use the default configuration
155+
virtual_lines = true,
156+
157+
-- Alternatively, customize specific options
158+
-- virtual_lines = {
159+
-- -- Only show virtual line diagnostics for the current cursor line
160+
-- current_line = true,
161+
-- },
162+
}
142163
end

0 commit comments

Comments
 (0)