More tweaks. Getting to wher eI like things
This commit is contained in:
parent
8b1be406ea
commit
fd71a2111a
234
init.lua
234
init.lua
|
@ -4,9 +4,9 @@
|
|||
vim.g.mapleader = ' '
|
||||
vim.g.maplocalleader = ' '
|
||||
|
||||
local preferred_border = 'single'
|
||||
local preferred_transparency = 0
|
||||
local layer_theme = "evening"
|
||||
local preferred_border = vim.g.pref_border_style or 'single'
|
||||
local preferred_transparency = vim.g.pref_blend or 0
|
||||
local layer_theme = vim.g.pref_layer_colorscheme
|
||||
local alt_theme = "catppuccin-mocha"
|
||||
local theme_light = "tokyonight-day"
|
||||
local theme_dark = "retrobox"
|
||||
|
@ -71,9 +71,9 @@ require('lazy').setup({
|
|||
},
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
{ "<leader>qs", function() require("persistence").load() end, desc = "Restore Session" },
|
||||
{ "<leader>ql", function() require("persistence").load({ last = true }) end, desc = "Restore Last Session" },
|
||||
{ "<leader>qd", function() require("persistence").stop() end, desc = "Don't Save Current Session" },
|
||||
{ "<leader>ss", function() require("persistence").load() end, desc = "Restore Session" },
|
||||
{ "<leader>sl", function() require("persistence").load({ last = true }) end, desc = "Restore Last Session" },
|
||||
{ "<leader>sd", function() require("persistence").stop() end, desc = "Don't Save Current Session" },
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -98,77 +98,6 @@ require('lazy').setup({
|
|||
},
|
||||
},
|
||||
'sudormrfbin/cheatsheet.nvim',
|
||||
{
|
||||
-- LSP Configuration & Plugins
|
||||
'neovim/nvim-lspconfig',
|
||||
dependencies = {
|
||||
{
|
||||
-- https://github.com/onsails/lspkind.nvim#configuration
|
||||
'onsails/lspkind.nvim' },
|
||||
-- Automatically install LSPs to stdpath for neovim
|
||||
{
|
||||
'williamboman/mason.nvim',
|
||||
config = true,
|
||||
opts = {
|
||||
ui = {
|
||||
border = preferred_border,
|
||||
icons = {
|
||||
package_installed = "✓",
|
||||
package_pending = "➜",
|
||||
package_uninstalled = "✗"
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
{ 'williamboman/mason-lspconfig.nvim' },
|
||||
{ 'folke/lsp-colors.nvim' },
|
||||
|
||||
-- Useful status updates for LSP
|
||||
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
|
||||
{ 'j-hui/fidget.nvim', tag = 'legacy', opts = {} },
|
||||
|
||||
-- Additional lua configuration, makes nvim stuff amazing!
|
||||
'folke/neodev.nvim',
|
||||
'b0o/SchemaStore.nvim',
|
||||
{
|
||||
-- https://github.com/rmagatti/goto-preview#%EF%B8%8F-configuration
|
||||
'rmagatti/goto-preview',
|
||||
opts = {
|
||||
default_mappings = true,
|
||||
opacity = 0,
|
||||
dismiss_on_move = true,
|
||||
},
|
||||
-- init = function()
|
||||
-- vim.keymap.set("n", "gp", "<cmd>lua require('goto-preview').goto_preview_definition()<CR>",
|
||||
-- { noremap = true, desc = '[G]o to Definition [P]review' })
|
||||
-- end,
|
||||
}
|
||||
},
|
||||
},
|
||||
--[[
|
||||
{
|
||||
-- https://github.com/pmizio/typescript-tools.nvim#%EF%B8%8F-configuration
|
||||
"pmizio/typescript-tools.nvim",
|
||||
dependencies = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" },
|
||||
ft = { 'typescript', 'typescript-react' },
|
||||
opts = {
|
||||
settings = {
|
||||
separate_diagnostic_server = true,
|
||||
tsserver_path = "/Users/oobleck/Library/pnpm/tsserver",
|
||||
expose_as_code_action = { "fix_all", "add_missing_imports", "remove_unused" },
|
||||
},
|
||||
},
|
||||
keys = {
|
||||
{ "<Leader>co", "<cmd>TSToolsOrganizeImports<cr>", desc = "[O]rganize Imports" },
|
||||
{ "<Leader>cs", "<cmd>TSToolsSortImports<cr>", desc = "[S]ort Impots" },
|
||||
{ "<Leader>cu", "<cmd>TSToolsRemoveUnusedImports<cr>", desc = "Remove [u]nused imports" },
|
||||
{ "<leader>cU", "<cmd>TSToolsRemoveUnused<cr>", desc = "Remove unused statements" },
|
||||
{ "<Leader>cm", "<cmd>TSToolsAddMissingImports<cr>", desc = "Add all [m]issing imports" },
|
||||
{ "<Leader>cf", "<cmd>TSToolsFixAll<cr>", desc = "Fix all" },
|
||||
{ "gd", "<cmd>TSToolsGoToSourceDefinition<cr>", desc = "[G]o to source [d]efinition" },
|
||||
},
|
||||
},
|
||||
]] --
|
||||
-- {
|
||||
-- 'nvimdev/lspsaga.nvim',
|
||||
-- event = "LspAttach",
|
||||
|
@ -260,29 +189,18 @@ require('lazy').setup({
|
|||
--
|
||||
-- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins
|
||||
{ import = 'custom.plugins' },
|
||||
{ import = 'custom.plugins.languages' },
|
||||
}, lazyConfig)
|
||||
|
||||
-- Set other options
|
||||
vim.cmd.colorscheme(require('custom.helpers.colorscheme'))
|
||||
|
||||
-- [[ Basic Keymaps ]]
|
||||
|
||||
-- [[ Sort tabs automatically ]]
|
||||
vim.api.nvim_create_autocmd({ 'BufAdd' }, {
|
||||
pattern = "*",
|
||||
command = 'BufferOrderByDirectory',
|
||||
})
|
||||
|
||||
-- [[ Highlight on yank ]]
|
||||
-- See `:help vim.highlight.on_yank()`
|
||||
local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true })
|
||||
vim.api.nvim_create_autocmd('TextYankPost', {
|
||||
callback = function()
|
||||
vim.highlight.on_yank()
|
||||
end,
|
||||
group = highlight_group,
|
||||
pattern = '*',
|
||||
})
|
||||
-- vim.api.nvim_create_autocmd({ "BufReadPost,FileReadPost" }, {
|
||||
-- -- https://www.jmaguire.tech/posts/treesitter_folding/
|
||||
-- pattern = '*',
|
||||
-- command = 'normal zR',
|
||||
-- })
|
||||
|
||||
-- [[ Configure Telescope ]]
|
||||
-- See `:help telescope` and `:help telescope.setup()`
|
||||
|
@ -295,6 +213,12 @@ require('telescope').setup {
|
|||
},
|
||||
},
|
||||
},
|
||||
pickers = {
|
||||
colorscheme = {
|
||||
-- https://github.com/nvim-telescope/telescope.nvim/issues/1961
|
||||
enable_preview = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- Enable telescope fzf native, if installed
|
||||
|
@ -304,7 +228,8 @@ pcall(require('telescope').load_extension, 'fzf')
|
|||
-- See `:help nvim-treesitter`
|
||||
require('nvim-treesitter.configs').setup {
|
||||
-- Add languages to be installed here that you want installed for treesitter
|
||||
ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'typescript', 'vimdoc', 'vim' },
|
||||
ensure_installed = { 'lua', 'rust', 'tsx', 'typescript', 'javascript', 'astro', 'svelte',
|
||||
'vimdoc', 'vim', 'markdown', 'css', 'json', 'yaml', 'bash' },
|
||||
|
||||
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
|
||||
auto_install = false,
|
||||
|
@ -366,124 +291,11 @@ require('nvim-treesitter.configs').setup {
|
|||
},
|
||||
}
|
||||
|
||||
-- [[ Configure LSP ]]
|
||||
-- This function gets run when an LSP connects to a particular buffer.
|
||||
local on_attach = function(_, bufnr)
|
||||
-- NOTE: Remember that lua is a real programming language, and as such it is possible
|
||||
-- to define small helper and utility functions so you don't have to repeat yourself
|
||||
-- many times.
|
||||
--
|
||||
-- In this case, we create a function that lets us more easily define mappings specific
|
||||
-- for LSP related items. It sets the mode, buffer and description for us each time.
|
||||
local nmap = function(keys, func, desc)
|
||||
if desc then
|
||||
desc = 'LSP: ' .. desc
|
||||
end
|
||||
|
||||
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
|
||||
end
|
||||
|
||||
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
|
||||
-- nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
|
||||
nmap('<Leader>ca', require("actions-preview").code_actions, '[C]ode [A]ction')
|
||||
|
||||
nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
|
||||
nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
|
||||
nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation')
|
||||
nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
|
||||
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
|
||||
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
|
||||
|
||||
-- See `:help K` for why this keymap
|
||||
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
|
||||
nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
|
||||
|
||||
-- Lesser used LSP functionality
|
||||
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
|
||||
nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
|
||||
nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
|
||||
nmap('<leader>wl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, '[W]orkspace [L]ist Folders')
|
||||
|
||||
-- Create a command `:Format` local to the LSP buffer
|
||||
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
|
||||
vim.lsp.buf.format()
|
||||
end, { desc = 'Format current buffer with LSP' })
|
||||
end
|
||||
|
||||
-- Enable the following language servers
|
||||
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
|
||||
--
|
||||
-- Add any additional override configuration in the following tables. They will be passed to
|
||||
-- the `settings` field of the server config. You must look up that documentation yourself.
|
||||
--
|
||||
-- If you want to override the default filetypes that your language server will attach to you can
|
||||
-- define the property 'filetypes' to the map in question.
|
||||
local servers = {
|
||||
rust_analyzer = {},
|
||||
tsserver = {},
|
||||
-- eslint_d = {},
|
||||
-- shfmt = {},
|
||||
-- beautysh = {},
|
||||
-- ['css-lsp'] = {},
|
||||
-- ['cssmodules-language-server'] = {},
|
||||
rome = {},
|
||||
-- prettierd = {},
|
||||
-- markdownlint = { filetypes = { 'md', 'mdx', 'mmd' } },
|
||||
html = { filetypes = { 'html', 'twig', 'hbs' } },
|
||||
-- fixjson = { filetypes = { 'json', 'json5' } },
|
||||
-- yamllint = { filetypes = { 'yaml', 'docker' } },
|
||||
|
||||
lua_ls = {
|
||||
Lua = {
|
||||
workspace = { checkThirdParty = false },
|
||||
telemetry = { enable = false },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- Setup neovim lua configuration
|
||||
require('neodev').setup()
|
||||
|
||||
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
|
||||
|
||||
|
||||
-- Ensure the servers above are installed
|
||||
local mason_lspconfig = require 'mason-lspconfig'
|
||||
|
||||
mason_lspconfig.setup {
|
||||
ensure_installed = vim.tbl_keys(servers),
|
||||
}
|
||||
|
||||
mason_lspconfig.setup_handlers {
|
||||
function(server_name)
|
||||
require('lspconfig')[server_name].setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
settings = servers[server_name],
|
||||
filetypes = (servers[server_name] or {}).filetypes,
|
||||
}
|
||||
end
|
||||
}
|
||||
|
||||
require('lspconfig').jsonls.setup({
|
||||
settings = {
|
||||
json = {
|
||||
schemas = require('schemastore').json.schemas(),
|
||||
validate = { enable = true },
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
--[[ Keymaps ]]
|
||||
require('custom.keymaps')
|
||||
require('custom.usercommands')
|
||||
require('custom.autocommands')
|
||||
require('custom.gui-neovide')
|
||||
|
||||
if vim.g.neovide then
|
||||
-- Put anything you want to happen only in Neovide herei
|
||||
-- vim.o.guifont = "SauceCodePro Nerd Font:h13"
|
||||
vim.o.guifont = "JetBrainsMono Nerd Font:h13"
|
||||
vim.g.neovide_confirm_quit = true
|
||||
end
|
||||
-- The line beneath this is called `modeline`. See `:help modeline`
|
||||
-- vim: ts=2 sts=2 sw=2 et
|
||||
|
|
|
@ -0,0 +1,202 @@
|
|||
local api = vim.api
|
||||
local fn = vim.fn
|
||||
local M = {}
|
||||
-- function to create a list of commands and convert them to autocommands
|
||||
-------- This function is taken from https://github.com/norcalli/nvim_utils
|
||||
function M.nvim_create_augroups(definitions)
|
||||
for group_name, definition in pairs(definitions) do
|
||||
api.nvim_command('augroup ' .. group_name)
|
||||
api.nvim_command('autocmd!')
|
||||
for _, def in ipairs(definition) do
|
||||
local command = table.concat(vim.tbl_flatten { 'autocmd', def }, ' ')
|
||||
api.nvim_command(command)
|
||||
end
|
||||
api.nvim_command('augroup END')
|
||||
end
|
||||
end
|
||||
|
||||
function M.create_autogroups(definitions)
|
||||
for group_name, commands in pairs(definitions) do
|
||||
local group = api.nvim_create_augroup(group_name, { clear = false })
|
||||
|
||||
for _, def in ipairs(commands) do
|
||||
local events = def[1]
|
||||
local pattern = def[2]
|
||||
local cmd_or_callback = def[3]
|
||||
local desc = def[4] and def[4].desc
|
||||
local is_callback = type(cmd_or_callback) ~= 'string'
|
||||
local opts = {
|
||||
group = group,
|
||||
pattern = pattern,
|
||||
desc = desc,
|
||||
-- callback = is_callback and cmd_or_callback or nil,
|
||||
-- command = not is_callback and cmd_or_callback or nil,
|
||||
}
|
||||
|
||||
if is_callback then
|
||||
opts.callback = cmd_or_callback
|
||||
else
|
||||
opts.command = cmd_or_callback
|
||||
end
|
||||
|
||||
print(group_name, events, type(cmd_or_callback), 'is_callback', is_callback, vim.inspect(opts))
|
||||
api.nvim_create_autocmd(events, opts)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local autoCommands = {
|
||||
open_folds = {
|
||||
{ "BufReadPost,FileReadPost", "*", "normal zR" }
|
||||
},
|
||||
tabs = {
|
||||
-- [[ Sort tabs automatically ]]
|
||||
{ 'BufAdd', '*', vim.g.pref_tab_order },
|
||||
-- {
|
||||
-- 'BufAdd', '*',
|
||||
-- function()
|
||||
-- print('Sorting tabs by', vim.g.pref_autoformat)
|
||||
-- vim.cmd(vim.g.pref_tab_order or [[BufferOrderByDirectory]])
|
||||
-- end,
|
||||
-- { desc = 'Auto sort tabs by `vim.g.pref_tab_order`' },
|
||||
-- }
|
||||
},
|
||||
}
|
||||
|
||||
M.nvim_create_augroups(autoCommands)
|
||||
-- M.create_autogroups(autoCommands)
|
||||
|
||||
-- [[ Highlight on yank ]]
|
||||
-- See `:help vim.highlight.on_yank()`
|
||||
local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true })
|
||||
vim.api.nvim_create_autocmd('TextYankPost', {
|
||||
callback = function()
|
||||
vim.highlight.on_yank()
|
||||
end,
|
||||
group = highlight_group,
|
||||
pattern = '*',
|
||||
})
|
||||
|
||||
-- vim.api.nvim_create_autocmd({ 'BufDelete' }, {
|
||||
-- pattern = "*",
|
||||
-- callback = function()
|
||||
-- local bufs = vim.api.nvim_list_bufs()
|
||||
-- local loaded_bufs = {}
|
||||
-- for _, buf in ipairs(bufs) do
|
||||
-- if vim.api.nvim_buf_is_loaded(buf) then
|
||||
-- loaded_bufs[#loaded_bufs + 1] = buf
|
||||
-- end
|
||||
-- end
|
||||
-- if #loaded_bufs == 0 then
|
||||
-- vim.cmd([[:lua MiniStarter.open()]])
|
||||
-- end
|
||||
-- print('Buffer closed', #loaded_bufs, #bufs)
|
||||
-- -- local bufnr = fn.bufnr('%')
|
||||
-- -- print('Deleting buffer ' .. bufnr)
|
||||
-- -- if fn.bufname('%') == '' then
|
||||
-- -- require('mini.starter').open()
|
||||
-- -- end
|
||||
-- end,
|
||||
-- })
|
||||
|
||||
vim.api.nvim_create_autocmd({ "QuitPre" }, {
|
||||
-- https://github.com/nvim-tree/nvim-tree.lua/wiki/Auto-Close#marvinth01
|
||||
callback = function()
|
||||
local tree_wins = {}
|
||||
local floating_wins = {}
|
||||
local wins = vim.api.nvim_list_wins()
|
||||
for _, w in ipairs(wins) do
|
||||
local bufname = vim.api.nvim_buf_get_name(vim.api.nvim_win_get_buf(w))
|
||||
if bufname:match("NvimTree_") ~= nil then
|
||||
table.insert(tree_wins, w)
|
||||
end
|
||||
if vim.api.nvim_win_get_config(w).relative ~= '' then
|
||||
table.insert(floating_wins, w)
|
||||
end
|
||||
end
|
||||
if 1 == #wins - #floating_wins - #tree_wins then
|
||||
-- Should quit, so we close all invalid windows.
|
||||
for _, w in ipairs(tree_wins) do
|
||||
vim.api.nvim_win_close(w, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
vim.cmd([[highlight OobleckRulers guifg=#181825]])
|
||||
vim.api.nvim_create_autocmd({ 'BufEnter', 'ModeChanged', 'TextChanged' }, {
|
||||
pattern = { '*XXX' },
|
||||
desc = 'Draw virtual text "rulers" like in VSCode instead of colorcolumn',
|
||||
callback = function(opts)
|
||||
vim.o.colorcolumn = nil
|
||||
-- https://jdhao.github.io/2021/09/09/nvim_use_virtual_text/
|
||||
-- local bufn = opts.buf
|
||||
local bnr = vim.fn.bufnr('%')
|
||||
local ns_id = api.nvim_create_namespace('rulers')
|
||||
local rulers = { 80, 120 }
|
||||
-- local col_char = "│"
|
||||
local col_char = "┊"
|
||||
-- local col_char = "╷";
|
||||
-- local col_char = "░"
|
||||
|
||||
-- or vim.api.nvim_buf_line_count(0)
|
||||
local buf_lines_count = vim.fn.line('$')
|
||||
|
||||
for line = 0, buf_lines_count do
|
||||
for _, col_num in ipairs(rulers) do
|
||||
local opts = {
|
||||
id = (line * 1000) + col_num,
|
||||
virt_text_win_col = col_num,
|
||||
virt_text_hide = true,
|
||||
hl_mode = 'combine',
|
||||
-- hl_group = "ColorColumn",
|
||||
-- OobleckRulers Delimiter NonText Comment
|
||||
virt_text = { { col_char, { "Comment" } } },
|
||||
virt_text_pos = 'overlay',
|
||||
-- conceal = col_char,
|
||||
ui_watched = true,
|
||||
priority = 1,
|
||||
}
|
||||
|
||||
vim.api.nvim_buf_set_extmark(bnr, ns_id, line, 0, opts)
|
||||
end
|
||||
end
|
||||
|
||||
-- nvim_buf_del_extmark(bnr, ns_id, id)
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
local general_auto_group = api.nvim_create_augroup('GenrealAutoStuff', { clear = false })
|
||||
vim.cmd([[
|
||||
" BufferCurrentERROR
|
||||
hi oobERROR guibg=DarkRed guifg=White
|
||||
hi oobWARN guibg=Gold guifg=White
|
||||
hi oobINFO guibg=LightBlue guifg=White
|
||||
hi oobHINT guibg=DarkCyan guifg=White
|
||||
]])
|
||||
api.nvim_create_autocmd({ 'BufEnter', 'ModeChanged' }, {
|
||||
pattern = { '*.*' },
|
||||
-- TODO: THings
|
||||
-- TODO (Spencer) - THings
|
||||
-- NOTE: THis is a note
|
||||
-- FIX: Fix This
|
||||
-- FIXME: Fix this
|
||||
-- BUG: There is a vbug in this highlighting?
|
||||
-- WARNING: THis is a warning
|
||||
-- WARN (spencer): this is a warning
|
||||
desc = "General auto run stuff that doesn't really need a discrete AutoCmd",
|
||||
group = general_auto_group,
|
||||
callback = function()
|
||||
vim.cmd([[
|
||||
" syntax match OobleckTODO /(?<=^[\W\s]+)(TODO|FIXME|BUG).*[:\-]/
|
||||
" syntax match OobleckWARN /(?<=^[\W\s]+)WARN.*[:\-]/
|
||||
" syntax match OobleckNOTE /(?<=^[\W\s]+)NOTE.*[:\-]/
|
||||
|
||||
syntax match oobERROR /\v<((FIX[ME]{0,2}|BUG|XXX))/ containedin=.*[Cc]omment
|
||||
syntax match oobWARN /\v<((WARN[ING]{0,3}))/ containedin=.*[Cc]omment
|
||||
syntax match oobHINT /\v<((NOTE))/ containedin=.*[Cc]omment
|
||||
syntax match oobINFO /\v<((TODO))/ containedin=.*[Cc]omment
|
||||
]])
|
||||
end,
|
||||
})
|
|
@ -0,0 +1,27 @@
|
|||
if vim.g.neovide then
|
||||
-- Helper function for transparency formatting
|
||||
local alpha = function()
|
||||
return string.format("%x", math.floor(255 * (vim.g.transparency or 0.8)))
|
||||
end
|
||||
-- Put anything you want to happen only in Neovide herei
|
||||
-- vim.o.guifont = "SauceCodePro Nerd Font:h13"
|
||||
vim.o.guifont = "JetBrainsMono Nerd Font:h13:#e-subpixelantialias"
|
||||
vim.g.neovide_confirm_quit = true
|
||||
|
||||
-- g:neovide_transparency should be 0 if you want to unify transparency of content and title bar.
|
||||
vim.g.neovide_transparency = 0.0
|
||||
vim.g.transparency = 0.9
|
||||
vim.g.neovide_background_color = "#0f1117" .. alpha()
|
||||
vim.g.neovide_floating_blur_amount_x = 2.0
|
||||
vim.g.neovide_floating_blur_amount_y = vim.g.neovide_floating_blur_amount_x
|
||||
vim.g.neovide_underline_automatic_scaling = true
|
||||
|
||||
-- follow system theme setting
|
||||
vim.g.neovide_theme = 'auto'
|
||||
|
||||
-- Keymaps
|
||||
vim.keymap.set({ 'n', 'i', 's' }, '<D-v>', '<esc>]P<cr>', { desc = 'Paste before cursor (and align)' })
|
||||
vim.keymap.set({ 'n', 'i' }, '<D-s>', '<cmd>:update<cr>', { desc = "Save current buffer/file" })
|
||||
-- vim.keymap.set({ 'n', 'i' }, '<D-M-s>', '<cmd>:bufdo update<cr>', { desc = "Save all unsaved buffers/files" })
|
||||
end
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
if vim.fn.exists(':GuiFont') then
|
||||
vim.o.mouuse = 'a'
|
||||
|
||||
vim.cmd([[GuiFont 'JetBrainsMono Nerd Font:h13']])
|
||||
end
|
|
@ -17,6 +17,7 @@ end
|
|||
|
||||
-- Uncomment the colorscheme to use
|
||||
local colorscheme = get_if_available("catppuccin-mocha")
|
||||
-- local colorscheme = get_if_available("minicyan")
|
||||
-- local colorscheme = get_if_available('gruvbox')
|
||||
-- local colorscheme = get_if_available('rose-pine')
|
||||
-- local colorscheme = get_if_available('everforest')
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
-- Box drawing symbols: https://wikiless.esmailelbob.xyz/wiki/Box-drawing_character
|
||||
-- https://altcodeunicode.com/alt-codes-box-form-drawing-block-element-symbols/
|
||||
return {
|
||||
dap = {
|
||||
Stopped = { " ", "DiagnosticWarn", "DapStoppedLine" },
|
||||
|
@ -16,6 +18,7 @@ return {
|
|||
added = " ",
|
||||
modified = " ",
|
||||
removed = " ",
|
||||
delete = "⌫ ",
|
||||
},
|
||||
kinds = {
|
||||
Array = " ",
|
||||
|
|
|
@ -1,23 +1,31 @@
|
|||
local tb = require('telescope.builtin')
|
||||
|
||||
function kmap(keys, cmd, desc, mode)
|
||||
vim.keymap.set(mode or 'n', keys, cmd, { desc = desc})
|
||||
end
|
||||
|
||||
--[[ This file contains general and specific plugin keymaps. ]]
|
||||
|
||||
-- Tab/Shift+Tab indenting in most modes.
|
||||
vim.keymap.set('n', '<Tab>', '>>_')
|
||||
kmap('<Tab>', '>>_')
|
||||
vim.keymap.set('n', '<S-Tab>', '<<_')
|
||||
vim.keymap.set('v', '<Tab>', '>gv')
|
||||
vim.keymap.set('v', '<S-Tab>', '<gv')
|
||||
vim.keymap.set('i', '<S-Tab>', '<C-D>')
|
||||
|
||||
vim.keymap.set({ "n" }, 'gp', '<Noop>', { noremap = true, silent = true })
|
||||
vim.keymap.set({ "n" }, 'gp', '<Nop>', { noremap = true, silent = true })
|
||||
vim.keymap.set({ 'n' }, '<cr>', 'pumvisible() ? "<C-y>" : "<C-g>u<cr>"', { expr = true })
|
||||
-- vim.keymap.set({ 'n' }, '<esc>', 'pumvisible() ? "<C-e>" : "<esc>"', { expr = true })
|
||||
|
||||
-- Keymaps for better default experience
|
||||
-- See `:help vim.keymap.set()`
|
||||
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
|
||||
-- vim.keymap.set({ 'n', 'i' }, '<C-s>', '<ESC><cmd>w<CR>', {desc = 'Save current Buffer' })
|
||||
vim.keymap.set({ 'n', 'i' }, '<C-S>', '<ESC><cmd>wa<CR>', { desc = '[S]ave all modified buffers' })
|
||||
vim.keymap.set('n', '<Leader>qq', '<CMD>qa<CR>', { desc = '[Q]uit vim' })
|
||||
|
||||
-- Uses Mini.bufremove's :bdelete
|
||||
vim.keymap.set('n', '<Leader>x', '<CMD>bdelete<CR>', { desc = '[B]uffer [d]elete (close buffer)' })
|
||||
vim.keymap.set('n', '<Leader>xx', '<CMD>bufdo bdelete<CR>', { desc = '[B]uffer [d]elete All (close all buffers)' })
|
||||
|
||||
-- Remap for dealing with word wrap
|
||||
vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
|
||||
|
@ -39,25 +47,26 @@ vim.keymap.set('n', '<Leader>mt', minimap.toggle, { desc = 'Minimap: [T]oggle op
|
|||
vim.keymap.set('n', '<Leader>mm', minimap.toggle, { desc = 'Minimap: (alias) [T]oggle open/closed' })
|
||||
-- [[ Code actioerver_path =s ]]
|
||||
-- vim.keymap.set({'n'}, '<Leader>ca')
|
||||
vim.keymap.set({ 'n' }, '<Leader>cf', '<CMD>Format<CR>', { silent = true, desc = '[F]ormat current Buffer' })
|
||||
-- vim.keymap.set({ 'n' }, '<Leader>cf', '<CMD>Format<CR>', { silent = true, desc = '[F]ormat current Buffer' })
|
||||
|
||||
-- See `:help telescope.builtin`
|
||||
vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' })
|
||||
vim.keymap.set('n', '<leader><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' })
|
||||
vim.keymap.set('n', '<leader>?', tb.oldfiles, { desc = '[?] Find recently opened files' })
|
||||
vim.keymap.set('n', '<leader><space>', tb.buffers, { desc = '[ ] Find existing buffers' })
|
||||
vim.keymap.set('n', '<leader>/', function()
|
||||
-- You can pass additional configuration to telescope to change theme, layout, etc.
|
||||
require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
|
||||
winblend = vim.o.winblend,
|
||||
tb.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
|
||||
winblend = vim.g.pref_blend,
|
||||
previewer = false,
|
||||
})
|
||||
end, { desc = '[/] Fuzzily search in current buffer' })
|
||||
end, { desc = '[/] Fuzzy search in current buffer' })
|
||||
|
||||
vim.keymap.set('n', '<leader>gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' })
|
||||
vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
|
||||
vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
|
||||
vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
|
||||
vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
|
||||
vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })
|
||||
vim.keymap.set('n', '<leader>gf', tb.git_files, { desc = 'Search [G]it [F]iles' })
|
||||
vim.keymap.set('n', '<leader>sf', tb.find_files, { desc = '[S]earch [F]iles' })
|
||||
vim.keymap.set('n', '<leader>sh', tb.help_tags, { desc = '[S]earch [H]elp' })
|
||||
vim.keymap.set('n', '<leader>sw', tb.grep_string, { desc = '[S]earch current [W]ord' })
|
||||
vim.keymap.set('n', '<leader>sg', tb.live_grep, { desc = '[S]earch by [G]rep' })
|
||||
vim.keymap.set('n', '<leader>sd', tb.diagnostics, { desc = '[S]earch [D]iagnostics' })
|
||||
vim.keymap.set('n', '<Leader>C', tb.colorscheme, { desc = 'Pick a Colorscheme' })
|
||||
|
||||
|
||||
-- Diagnostic keymaps
|
||||
|
@ -65,3 +74,15 @@ vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous dia
|
|||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })
|
||||
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
|
||||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
|
||||
|
||||
|
||||
-- Code folding
|
||||
-- vim.keymap.set('n', 'FF', '<cmd>za<cr>', { desc = 'Toggle code [F]olding' })
|
||||
|
||||
-- [[ Wrap symbol under cursor in <symbol> ]]
|
||||
kmap('<C-W>', function()
|
||||
local wrap_char = vim.fn.input('Wrap with? ')
|
||||
vim.cmd('WrapSymbol ' .. wrap_char)
|
||||
end, '[W]rap word under cursor')
|
||||
|
||||
-- kmap('<C-R><C-R>', '<cmd>ReloadConfig<cr>', '[R]reload nvim config')
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
local globals = {
|
||||
loaded_netrw = 1,
|
||||
loaded_netrwPlugin = 1,
|
||||
|
||||
-- [[ Custom globals prefixed with "pref_" ]]
|
||||
pref_tab_order = 'BufferOrderByDirectory',
|
||||
pref_border_style = 'single',
|
||||
pref_blend = 0,
|
||||
pref_colorscheme = 'catppuccin',
|
||||
pref_layer_colorscheme = 'catppuccin-macchiato',
|
||||
pref_autoformat = false,
|
||||
}
|
||||
|
||||
for opt, val in pairs(globals) do
|
||||
vim.g[opt] = val
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- See `:help vim.o`
|
||||
local opts = {
|
||||
shiftwidth = 2,
|
||||
|
@ -8,12 +27,12 @@ local opts = {
|
|||
undofile = true,
|
||||
ignorecase = true,
|
||||
smartcase = true,
|
||||
updatetime = 250,
|
||||
updatetime = 500,
|
||||
timeoutlen = 300,
|
||||
-- Set completeopt to have a better completion experience
|
||||
completeopt = 'longest,menuone,noselect',
|
||||
winblend = 0,
|
||||
pumblend = 0,
|
||||
winblend = vim.g.pref_blend or 0,
|
||||
pumblend = vim.g.pref_blend or 0,
|
||||
tabstop = 2,
|
||||
expandtab = true,
|
||||
wrap = false,
|
||||
|
@ -21,12 +40,17 @@ local opts = {
|
|||
number = true,
|
||||
relativenumber = false,
|
||||
textwidth = 80,
|
||||
colorcolumn = '80,120',
|
||||
}
|
||||
|
||||
local globals = {
|
||||
loaded_netrw = 1,
|
||||
loaded_netrwPlugin = 1,
|
||||
-- Draw the column on the right side of the o.textwidth, not under it.
|
||||
-- colorcolumn = '81,121',
|
||||
colorcolumn = '+1,+41',
|
||||
-- Keep the current line vertically centered when scrolling or jumping in
|
||||
-- a buffer.
|
||||
scrolloff = 6,
|
||||
|
||||
-- Code folding
|
||||
foldmethod = 'expr',
|
||||
foldexpr = 'nvim_treesitter#foldexpr()',
|
||||
}
|
||||
|
||||
-- Set options from table
|
||||
|
@ -34,6 +58,3 @@ for opt, val in pairs(opts) do
|
|||
vim.o[opt] = val
|
||||
end
|
||||
|
||||
for opt, val in pairs(globals) do
|
||||
vim.g[opt] = val
|
||||
end
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
return {
|
||||
{
|
||||
-- https://github.com/gsuuon/llm.nvim#configuration
|
||||
'gsuuon/llm.nvim',
|
||||
config = function()
|
||||
require('llm').setup({
|
||||
-- https://github.com/gsuuon/llm.nvim#prompts
|
||||
prompts = vim.tbl_extend('force', require('llm.prompts.starters'), {}),
|
||||
})
|
||||
|
||||
-- https://github.com/gsuuon/llm.nvim#-usage
|
||||
vim.keymap.set('n', '<leader>LC', '<cmd>LlmCancel<cr>', { desc = '[C]ancel current response' })
|
||||
vim.keymap.set('n', '<Leader>Ll', '<cmd>Llm<cr>', { desc = 'Start an [L]lm completion' })
|
||||
vim.keymap.set('n', '<Leader>LL', '<cmd>LlmSelect<cr>', { desc = 'Select the response under the cursor' })
|
||||
vim.keymap.set('n', '<leader>Ls', '<cmd>LlmShow<cr>',
|
||||
{ desc = '[S]how the response under the cursor if there is one' })
|
||||
vim.keymap.set('n', '<Leader>LD', '<c,d>LlmDelete<cr>', { desc = 'Delete the response under the cursor' })
|
||||
end,
|
||||
}
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
local icons = require('custom.helpers.icons')
|
||||
|
||||
return {
|
||||
-- {
|
||||
-- -- https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-completion.md#default-config
|
||||
|
@ -28,12 +30,13 @@ return {
|
|||
{ 'nat-418/cmp-color-names.nvim' },
|
||||
{ 'Jezda1337/nvim-html-css' },
|
||||
{ 'mmolhoek/cmp-scss' },
|
||||
|
||||
{ 'onsails/lspkind.nvim' },
|
||||
},
|
||||
opts = function()
|
||||
vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true })
|
||||
local cmp = require("cmp")
|
||||
local defaults = require("cmp.config.default")()
|
||||
local lspkind = require('lspkind')
|
||||
return {
|
||||
completion = {
|
||||
completeopt = "menu,menuone,noinsert",
|
||||
|
@ -81,13 +84,21 @@ return {
|
|||
{ name = "path" },
|
||||
}),
|
||||
formatting = {
|
||||
format = function(_, item)
|
||||
local icons = require("custom.helpers.icons").kinds
|
||||
if icons[item.kind] then
|
||||
item.kind = icons[item.kind] .. item.kind
|
||||
end
|
||||
return item
|
||||
end,
|
||||
-- format = function(_, item)
|
||||
-- local icons = require("custom.helpers.icons").kinds
|
||||
-- if icons[item.kind] then
|
||||
-- item.kind = icons[item.kind] .. item.kind
|
||||
-- end
|
||||
-- return item
|
||||
-- end,
|
||||
format = lspkind.cmp_format({
|
||||
-- https://github.com/onsails/lspkind.nvim#option-2-nvim-cmp
|
||||
mode = 'symbol_text',
|
||||
-- preset = 'codeicons',
|
||||
maxwidth = 75,
|
||||
ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first)
|
||||
-- symbol_map = icons.kinds,
|
||||
})
|
||||
},
|
||||
experimental = {
|
||||
ghost_text = {
|
||||
|
|
|
@ -1,37 +1,54 @@
|
|||
local prettierd = function()
|
||||
return {
|
||||
exe = "prettierd",
|
||||
args = { "--stdin-filepath", vim.fn.shellescape(vim.api.nvim_buf_get_name(0)), "--single-quote" },
|
||||
stdin = true,
|
||||
}
|
||||
end
|
||||
|
||||
return {
|
||||
{
|
||||
-- https://github.com/mhartington/formatter.nvim#configure
|
||||
'mhartington/formatter.nvim',
|
||||
config = function()
|
||||
local formatter = require('formatter')
|
||||
local util = require('formatter.util')
|
||||
|
||||
formatter.setup({
|
||||
require('formatter').setup({
|
||||
logging = true,
|
||||
log_level = vim.log.levels.WARN,
|
||||
filetype = {
|
||||
typescript = {
|
||||
require('formatter.filetypes.typescriptreact').prettier,
|
||||
require('formatter.filetypes.typescriptreact').prettierd,
|
||||
},
|
||||
javascript = {
|
||||
require('formatter.filetypes.javascriptreact').prettier,
|
||||
require('formatter.filetypes.typescriptreact').prettierd,
|
||||
},
|
||||
typescriptreact = {
|
||||
require('formatter.filetypes.typescriptreact').prettierd,
|
||||
},
|
||||
javascriptreact = {
|
||||
require('formatter.filetypes.typescriptreact').prettierd,
|
||||
},
|
||||
markdown = {
|
||||
require('formatter.filetypes.markdown').prettier,
|
||||
require('formatter.filetypes.markdown').prettierd,
|
||||
},
|
||||
html = {
|
||||
require('formatter.filetypes.html').prettier,
|
||||
require('formatter.filetypes.html').prettierd,
|
||||
},
|
||||
scss = {
|
||||
require('formatter.filetypes.css').prettierd,
|
||||
},
|
||||
css = {
|
||||
require('formatter.filetypes.css').prettier,
|
||||
require('formatter.filetypes.css').prettierd,
|
||||
},
|
||||
json = {
|
||||
require('formatter.filetypes.json').prettier,
|
||||
require('formatter.filetypes.json').prettierd,
|
||||
},
|
||||
yaml = {
|
||||
require('formatter.filetypes.yaml').yamlfmt,
|
||||
},
|
||||
svelte = {
|
||||
require('formatter.filetypes.svelte').prettier,
|
||||
require('formatter.filetypes.svelte').prettierd,
|
||||
},
|
||||
lua = {
|
||||
require("formatter.filetypes.lua").stylua,
|
||||
|
@ -51,6 +68,13 @@ return {
|
|||
}
|
||||
},
|
||||
})
|
||||
|
||||
-- vim.api.nvim_create_autocmd('BufWritePre', {
|
||||
-- pattern = '*',
|
||||
-- callback = function()
|
||||
-- vim.cmd([[Format]])
|
||||
-- end,
|
||||
-- })
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -4,21 +4,24 @@ return {
|
|||
{
|
||||
-- https://github.com/mfussenegger/nvim-lint#readme
|
||||
'mfussenegger/nvim-lint',
|
||||
event = 'VeryLazy',
|
||||
-- event = 'VeryLazy',
|
||||
config = function()
|
||||
local linter = require('lint')
|
||||
|
||||
linter.linters_by_ft = {
|
||||
markdown = { 'vale' },
|
||||
typescript = { 'eslint' },
|
||||
javascript = { 'eslint' },
|
||||
typescript = { 'eslintd' },
|
||||
javascript = { 'eslintd' },
|
||||
}
|
||||
|
||||
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
|
||||
callback = function()
|
||||
linter.try_lint()
|
||||
end,
|
||||
})
|
||||
-- vim.api.nvim_create_autocmd({ "BufWritePre" }, {
|
||||
-- callback = function()
|
||||
-- require('lint').try_lint()
|
||||
-- end,
|
||||
-- })
|
||||
|
||||
vim.api.nvim_create_user_command('NvimLint', function() linter.try_lint() end, { desc = 'Lint the current buffer' })
|
||||
vim.keymap.set('n', '<leader>cl', '<cmd>NvimLint<cr>', { desc = '[L]int the current buffer' })
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1,16 +1,62 @@
|
|||
return {
|
||||
-- Detect tabstop and shiftwidth automatically
|
||||
'tpope/vim-sleuth',
|
||||
'gpanders/editorconfig.nvim',
|
||||
'VidocqH/lsp-lens.nvim',
|
||||
{
|
||||
-- https://github.com/VidocqH/lsp-lens.nvim#configs
|
||||
'VidocqH/lsp-lens.nvim',
|
||||
config = true,
|
||||
},
|
||||
{
|
||||
-- https://github.com/anuvyklack/pretty-fold.nvim#foldtext-configuration
|
||||
'anuvyklack/pretty-fold.nvim',
|
||||
dependencies = {
|
||||
{
|
||||
-- https://github.com/anuvyklack/fold-preview.nvim#configuration
|
||||
'anuvyklack/fold-preview.nvim',
|
||||
config = true,
|
||||
opts = {
|
||||
auto = 200,
|
||||
border = vim.g.pref_border_style,
|
||||
},
|
||||
}
|
||||
},
|
||||
config = true,
|
||||
opts = {
|
||||
remove_fold_markers = true,
|
||||
},
|
||||
},
|
||||
{
|
||||
-- https://github.com/lukas-reineke/indent-blankline.nvim#setup
|
||||
-- Add indentation guides even on blank lines
|
||||
'lukas-reineke/indent-blankline.nvim',
|
||||
-- See `:help indent_blankline.txt`
|
||||
opts = {
|
||||
char = '┊',
|
||||
show_trailing_blankline_indent = false,
|
||||
},
|
||||
main = 'ibl',
|
||||
config = function()
|
||||
-- See :h ibl.config
|
||||
local highlight = {
|
||||
"CursorColumn",
|
||||
"Whitespace",
|
||||
}
|
||||
local opts = {
|
||||
indent = {
|
||||
-- highlight = highlight,
|
||||
char = "",
|
||||
},
|
||||
whitespace = {
|
||||
highlight = highlight,
|
||||
remove_blankline_trail = true,
|
||||
},
|
||||
scope = {
|
||||
enabled = true,
|
||||
-- highlight = highlight,
|
||||
show_start = true,
|
||||
show_end = true,
|
||||
char = "│",
|
||||
-- char = "|",
|
||||
priority = 500,
|
||||
},
|
||||
}
|
||||
require('ibl').setup(opts);
|
||||
end,
|
||||
},
|
||||
'echasnovski/mini.align',
|
||||
'echasnovski/mini.bracketed',
|
||||
|
@ -32,11 +78,35 @@ return {
|
|||
'echasnovski/mini.cursorword',
|
||||
'echasnovski/mini.move',
|
||||
{
|
||||
-- https://github.com/echasnovski/mini.pairs#default-config
|
||||
"echasnovski/mini.pairs",
|
||||
event = "VeryLazy",
|
||||
opts = {},
|
||||
config = true,
|
||||
opts = {
|
||||
mappings = {
|
||||
['('] = { action = 'open', pair = '()', neigh_pattern = '[^\\].' },
|
||||
['['] = { action = 'open', pair = '[]', neigh_pattern = '[^\\].' },
|
||||
['{'] = { action = 'open', pair = '{}', neigh_pattern = '[^\\].' },
|
||||
|
||||
[')'] = { action = 'close', pair = '()', neigh_pattern = '[^\\].' },
|
||||
[']'] = { action = 'close', pair = '[]', neigh_pattern = '[^\\].' },
|
||||
['}'] = { action = 'close', pair = '{}', neigh_pattern = '[^\\].' },
|
||||
|
||||
['"'] = { action = 'closeopen', pair = '""', neigh_pattern = '[^\\].', register = { cr = false } },
|
||||
["'"] = { action = 'closeopen', pair = "''", neigh_pattern = '[^%a\\].', register = { cr = false } },
|
||||
['`'] = { action = 'closeopen', pair = '``', neigh_pattern = '[^\\].', register = { cr = false } },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
-- https://github.com/echasnovski/mini.surround#default-config
|
||||
'echasnovski/mini.surround',
|
||||
event = "VeryLazy",
|
||||
config = true,
|
||||
opts = {
|
||||
search_method = "cover_or_nearest",
|
||||
},
|
||||
},
|
||||
'echasnovski/mini.surround',
|
||||
-- 'echasnovski/mini.hlpatterns',
|
||||
-- Better text-objects
|
||||
{
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
return {
|
||||
{
|
||||
-- https://github.com/windwp/nvim-ts-autotag#override-default-values
|
||||
'windwp/nvim-ts-autotag',
|
||||
-- Not working correctly yet. Seems ot maybe conflict wth Emmet or something
|
||||
-- else.
|
||||
enabled = false,
|
||||
opts = {
|
||||
autotag = {
|
||||
enable = true,
|
||||
enable_rename = true,
|
||||
enable_close = true,
|
||||
enable_close_on_slash = true,
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
return {
|
||||
{
|
||||
-- https://github.com/pmizio/typescript-tools.nvim#%EF%B8%8F-configuration
|
||||
"pmizio/typescript-tools.nvim",
|
||||
dependencies = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" },
|
||||
ft = { "typescript", "typescript-react", "javascript", "javascript-react" },
|
||||
-- lazy = true,
|
||||
opts = {
|
||||
settings = {
|
||||
separate_diagnostic_server = true,
|
||||
publish_diagnostic_on = "change",
|
||||
tsserver_path = "/Users/oobleck/Library/pnpm/tsserver",
|
||||
expose_as_code_action = { "all" },
|
||||
},
|
||||
},
|
||||
config = true,
|
||||
keys = {
|
||||
{ "<Leader>co", "<cmd>TSToolsOrganizeImports<cr>", desc = "[O]rganize Imports" },
|
||||
{ "<Leader>cs", "<cmd>TSToolsSortImports<cr>", desc = "[S]ort Impots" },
|
||||
{ "<Leader>cu", "<cmd>TSToolsRemoveUnusedImports<cr>", desc = "Remove [u]nused imports" },
|
||||
{ "<leader>cU", "<cmd>TSToolsRemoveUnused<cr>", desc = "Remove unused statements" },
|
||||
{ "<Leader>cm", "<cmd>TSToolsAddMissingImports<cr>", desc = "Add all [m]issing imports" },
|
||||
{ "<Leader>cF", "<cmd>TSToolsFixAll<cr>", desc = "Fix all" },
|
||||
-- { "gd", "<cmd>TSToolsGoToSourceDefinition<cr>", desc = "[G]o to source [d]efinition" },
|
||||
},
|
||||
},
|
||||
}
|
|
@ -0,0 +1,263 @@
|
|||
-- LSP config setup (FOrmatting & liting)
|
||||
|
||||
local icons = require('custom.helpers.icons')
|
||||
local preferred_border = vim.g.pref_border_style or 'single'
|
||||
local preferred_transparency = vim.g.pref_blend or 0
|
||||
local diagnostics_format = function(diag)
|
||||
if diag.severity == vim.diagnostic.severity.ERROR then
|
||||
return icons.diagnostics.Error .. diag.message
|
||||
elseif diag.severity == vim.diagnostic.severity.WARN then
|
||||
return icons.diagnostics.Warn .. diag.message
|
||||
elseif diag.severity == vim.diagnostic.severity.HINT then
|
||||
return icons.diagnostics.Hint .. diag.message
|
||||
else
|
||||
return icons.diagnostics.Info .. diag.message
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
{
|
||||
-- LSP Configuration & Plugins
|
||||
'neovim/nvim-lspconfig',
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
dependencies = {
|
||||
-- Automatically install LSPs to stdpath for neovim
|
||||
{
|
||||
'williamboman/mason.nvim',
|
||||
config = true,
|
||||
opts = {
|
||||
ui = {
|
||||
border = preferred_border,
|
||||
icons = {
|
||||
package_installed = "✓",
|
||||
package_pending = "➜",
|
||||
package_uninstalled = "✗"
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
{ 'williamboman/mason-lspconfig.nvim' },
|
||||
{ 'folke/lsp-colors.nvim' },
|
||||
|
||||
-- Useful status updates for LSP
|
||||
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
|
||||
{ 'j-hui/fidget.nvim', tag = 'legacy', opts = {} },
|
||||
|
||||
-- Additional lua configuration, makes nvim stuff amazing!
|
||||
'folke/neodev.nvim',
|
||||
'b0o/SchemaStore.nvim',
|
||||
{
|
||||
-- Configured elsewhere?
|
||||
"hrsh7th/nvim-cmp",
|
||||
},
|
||||
-- {
|
||||
-- "hrsh7th/cmp-nvim-lsp",
|
||||
-- cond = function()
|
||||
-- return require("lazyvim.util").has("nvim-cmp")
|
||||
-- end,
|
||||
-- },
|
||||
{
|
||||
-- https://github.com/rmagatti/goto-preview#%EF%B8%8F-configuration
|
||||
'rmagatti/goto-preview',
|
||||
opts = {
|
||||
default_mappings = true,
|
||||
opacity = 0,
|
||||
dismiss_on_move = true,
|
||||
},
|
||||
-- keys = {
|
||||
-- { 'gp', function() require('goto-preview').goto_preview_definition() end, desc = '[G]o to Definition [P]review' },
|
||||
-- },
|
||||
-- init = function()
|
||||
-- vim.keymap.set("n", "gp", "<cmd>lua require('goto-preview').goto_preview_definition()<CR>",
|
||||
-- { noremap = true, desc = '[G]o to Definition [P]review' })
|
||||
-- end,
|
||||
}
|
||||
},
|
||||
opts = {
|
||||
-- options for vim.diagnostic.config()
|
||||
diagnostics = {
|
||||
virtual_text = {
|
||||
severity = vim.diagnostic.severity.ERROR,
|
||||
spacing = 4,
|
||||
source = "if_many",
|
||||
-- prefix = "◳ ",
|
||||
-- this will set set the prefix to a function that returns the diagnostics icon based on the severity
|
||||
-- this only works on a recent 0.10.0 build. Will be set to "●" when not supported
|
||||
-- prefix = "icons",
|
||||
format = diagnostics_format,
|
||||
},
|
||||
float = {
|
||||
source = "if_many", -- Or "always"
|
||||
format = diagnmstics_format,
|
||||
},
|
||||
|
||||
signs = true,
|
||||
underline = true,
|
||||
update_in_insert = true,
|
||||
severity_sort = true,
|
||||
},
|
||||
-- Enable the following language servers
|
||||
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
|
||||
--
|
||||
-- Add any additional override configuration in the following tables. They will be passed to
|
||||
-- the `settings` field of the server config. You must look up that documentation yourself.
|
||||
--
|
||||
-- If you want to override the default filetypes that your language server will attach to you can
|
||||
-- define the property 'filetypes' to the map in question.
|
||||
servers = {
|
||||
rust_analyzer = {},
|
||||
tsserver = { filetypes = {'typescript', 'javascript'} },
|
||||
stylelint_lsp = {
|
||||
stylelintplus = {
|
||||
autoFixOnFormat = true,
|
||||
},
|
||||
},
|
||||
eslint = {},
|
||||
bashls = {},
|
||||
-- beautysh = {},
|
||||
cssls = {},
|
||||
marksman = {},
|
||||
html = { filetypes = { 'html', 'twig', 'hbs' } },
|
||||
jsonls = {
|
||||
filetypes = { 'json', 'json5' },
|
||||
-- [[ TODO: Restore this once the load sequencing is figured out. ]]
|
||||
-- json = {
|
||||
-- schemas = require('schemastore').json.schemas(),
|
||||
-- validate = { enable = true },
|
||||
-- },
|
||||
},
|
||||
yamlls = { filetypes = { 'yaml', 'docker' } },
|
||||
rnix = {},
|
||||
nil_ls = {},
|
||||
|
||||
-- OT reqs
|
||||
-- ['java-language-server'] = {},
|
||||
jdtls = {},
|
||||
|
||||
lua_ls = {
|
||||
Lua = {
|
||||
workspace = { checkThirdParty = false },
|
||||
telemetry = { enable = false },
|
||||
},
|
||||
},
|
||||
},
|
||||
setup = {
|
||||
-- https://github.com/LazyVim/LazyVim/blob/a72a84972d85e5bbc6b9d60a0983b37efef21b8a/lua/lazyvim/plugins/lsp/init.lua#L79
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
-- [[ Configure LSP ]]
|
||||
local servers = opts.servers
|
||||
|
||||
-- This function gets run when an LSP connects to a particular buffer.
|
||||
local on_attach = function(_, bufnr)
|
||||
-- NOTE: Remember that lua is a real programming language, and as such it is possible
|
||||
-- to define small helper and utility functions so you don't have to repeat yourself
|
||||
-- many times.
|
||||
--
|
||||
-- In this case, we create a function that lets us more easily define mappings specific
|
||||
-- for LSP related items. It sets the mode, buffer and description for us each time.
|
||||
local nmap = function(keys, func, desc)
|
||||
if desc then
|
||||
desc = 'LSP: ' .. desc
|
||||
end
|
||||
|
||||
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
|
||||
end
|
||||
|
||||
nmap('<leader>cr', vim.lsp.buf.rename, '[R]ename')
|
||||
-- nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
|
||||
nmap('<Leader>ca', require("actions-preview").code_actions, '[C]ode [A]ction')
|
||||
nmap('<leader>cf', function()
|
||||
-- LSP formatter
|
||||
vim.cmd([[LspFormat]])
|
||||
|
||||
-- Format by formatter.nvim
|
||||
vim.cmd([[Format]])
|
||||
end, '[F]ormat current buffer')
|
||||
|
||||
nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
|
||||
nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
|
||||
nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation')
|
||||
nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
|
||||
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
|
||||
nmap('<leader>r', require('telescope.builtin').lsp_document_symbols, 'Alias: [D]ocument [S]ymbols')
|
||||
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
|
||||
|
||||
-- See `:help K` for why this keymap
|
||||
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
|
||||
nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
|
||||
|
||||
-- Lesser used LSP functionality
|
||||
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
|
||||
nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
|
||||
nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
|
||||
nmap('<leader>wl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, '[W]orkspace [L]ist Folders')
|
||||
|
||||
-- Create a command `:Format` local to the LSP buffer
|
||||
vim.api.nvim_buf_create_user_command(bufnr, 'LspFormat', function(_)
|
||||
vim.lsp.buf.format({ async = false })
|
||||
end, { desc = 'Format current buffer with LSP' })
|
||||
|
||||
-- Configure diagnostics display
|
||||
-- https://github.com/neovim/nvim-lspconfig/wiki/UI-customization#customizing-how-diagnostics-are-displayed
|
||||
vim.diagnostic.config(opts.diagnostics)
|
||||
|
||||
-- https://github.com/neovim/nvim-lspconfig/wiki/UI-customization#change-diagnostic-symbols-in-the-sign-column-gutter
|
||||
-- local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " }
|
||||
local signs = icons.diagnostics
|
||||
for type, icon in pairs(signs) do
|
||||
local hl = "DiagnosticSign" .. type
|
||||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
|
||||
end
|
||||
|
||||
-- You will likely want to reduce updatetime which affects CursorHold
|
||||
-- note: this setting is global and should be set only once
|
||||
-- https://github.com/neovim/nvim-lspconfig/wiki/UI-customization#show-line-diagnostics-automatically-in-hover-window
|
||||
-- vim.cmd [[autocmd! CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]]
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
local float_opts = {
|
||||
focusable = false,
|
||||
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
|
||||
border = preferred_border,
|
||||
source = 'if_many',
|
||||
prefix = ' ',
|
||||
scope = 'cursor',
|
||||
}
|
||||
vim.diagnostic.open_float(nil, float_opts)
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
-- https://github.com/LazyVim/LazyVim/blob/a72a84972d85e5bbc6b9d60a0983b37efef21b8a/lua/lazyvim/plugins/lsp/init.lua#L104
|
||||
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
|
||||
|
||||
-- Ensure the servers above are installed
|
||||
local mason_lspconfig = require 'mason-lspconfig'
|
||||
|
||||
mason_lspconfig.setup {
|
||||
ensure_installed = vim.tbl_keys(servers),
|
||||
}
|
||||
|
||||
mason_lspconfig.setup_handlers {
|
||||
function(server_name)
|
||||
require('lspconfig')[server_name].setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
settings = servers[server_name],
|
||||
filetypes = (servers[server_name] or {}).filetypes,
|
||||
}
|
||||
end
|
||||
}
|
||||
|
||||
-- Setup neovim lua configuration
|
||||
require('neodev').setup()
|
||||
end,
|
||||
},
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
local layer_theme = 'everforest'
|
||||
local layer_theme = vim.g.pref_layer_colorscheme or 'evening'
|
||||
local icons = require('custom.helpers.icons')
|
||||
|
||||
return {
|
||||
-- Color schemes
|
||||
|
@ -7,22 +8,43 @@ return {
|
|||
name = "catppuccin",
|
||||
},
|
||||
"sainnhe/everforest",
|
||||
{
|
||||
-- https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-base16.md#default-config
|
||||
'echasnovski/mini.base16',
|
||||
version = false,
|
||||
-- config = function()
|
||||
-- local palette = require('mini.base16')
|
||||
-- palette.setup({ palette = palette.mini_palette('#001e1e', '#cccccc', 50) })
|
||||
-- end,
|
||||
},
|
||||
|
||||
-- Other UI
|
||||
-- {
|
||||
-- -- Breadcrumbs dropbar (like IntelliJ's): Requires nvim 0.10+
|
||||
-- -- https://github.com/Bekaboo/dropbar.nvim#configuration
|
||||
-- 'Bekaboo/dropbar.nvim',
|
||||
-- dependencies = { 'nvim-tree/nvim-web-devicons' },
|
||||
-- opts = {
|
||||
-- sources = {
|
||||
-- path = {
|
||||
-- relative_to = function(_)
|
||||
-- return vim.fn.getcwd()
|
||||
-- end,
|
||||
-- },
|
||||
-- },
|
||||
-- },
|
||||
-- },
|
||||
{
|
||||
-- Breadcrumbs dropbar (like IntelliJ's)
|
||||
-- https://github.com/Bekaboo/dropbar.nvim#configuration
|
||||
'Bekaboo/dropbar.nvim',
|
||||
dependencies = { 'nvim-tree/nvim-web-devicons' },
|
||||
opts = {
|
||||
sources = {
|
||||
path = {
|
||||
relative_to = function(_)
|
||||
return vim.fn.getcwd()
|
||||
end,
|
||||
"LunarVim/breadcrumbs.nvim",
|
||||
dependencies = {
|
||||
"SmiteshP/nvim-navic",
|
||||
opts = {
|
||||
lsp = {
|
||||
auto_attach = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
config = true,
|
||||
},
|
||||
{ "folke/twilight.nvim" },
|
||||
{ "folke/zen-mode.nvim" },
|
||||
|
@ -63,14 +85,15 @@ return {
|
|||
{
|
||||
-- https://github.com/folke/styler.nvim#readme
|
||||
"folke/styler.nvim",
|
||||
enabled = false,
|
||||
config = true,
|
||||
-- enabled = false,
|
||||
-- lazy = true,
|
||||
opts = {
|
||||
themes = {
|
||||
help = { colorscheme = layer_theme },
|
||||
noice = { colorscheme = layer_theme },
|
||||
cmp = { colorscheme = layer_theme },
|
||||
neotree = { colorscheme = layer_theme },
|
||||
telescope = { colorscheme = layer_theme },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -80,7 +103,33 @@ return {
|
|||
keys = {
|
||||
{ "<leader>fe", "<cmd>NvimTreeToggle<cr>", desc = "Toggle the File [E]xplorer" },
|
||||
},
|
||||
opts = { filters = { git_ignored = false } },
|
||||
opts = {
|
||||
-- https://github.com/nvim-tree/nvim-tree.lua/blob/master/doc/nvim-tree-lua.txt
|
||||
filters = {
|
||||
git_ignored = false,
|
||||
},
|
||||
update_focused_file = {
|
||||
enable = true,
|
||||
},
|
||||
view = {
|
||||
signcolumn = 'auto',
|
||||
width = {
|
||||
min = 36,
|
||||
max = 50,
|
||||
},
|
||||
},
|
||||
renderer = {
|
||||
add_trailing = true,
|
||||
full_name = true,
|
||||
group_empty = true,
|
||||
highlight_git = true,
|
||||
highlight_diagnostics = true,
|
||||
icons = {
|
||||
git_placement = 'signcolumn',
|
||||
diagnostics_placement = 'signcolumn',
|
||||
},
|
||||
},
|
||||
},
|
||||
dependencies = {
|
||||
{ 'nvim-tree/nvim-web-devicons' },
|
||||
{
|
||||
|
@ -125,6 +174,9 @@ return {
|
|||
},
|
||||
{
|
||||
"folke/which-key.nvim",
|
||||
dependencies = {
|
||||
'anuvyklack/keymap-amend.nvim',
|
||||
},
|
||||
event = "VeryLazy",
|
||||
init = function()
|
||||
vim.o.timeout = true
|
||||
|
@ -172,31 +224,33 @@ return {
|
|||
highlight_alternate = false,
|
||||
icons = {
|
||||
diagnostics = {
|
||||
[vim.diagnostic.severity.ERROR] = { enabled = true },
|
||||
[vim.diagnostic.severity.WARN] = { enabled = false },
|
||||
[vim.diagnostic.severity.INFO] = { enabled = false },
|
||||
[vim.diagnostic.severity.HINT] = { enabled = false },
|
||||
[vim.diagnostic.severity.ERROR] = { enabled = true, icon = icons.diagnostics.Error },
|
||||
[vim.diagnostic.severity.WARN] = { enabled = false, icon = icons.diagnostics.Warn },
|
||||
[vim.diagnostic.severity.INFO] = { enabled = false, icon = icons.diagnostics.Info },
|
||||
[vim.diagnostic.severity.HINT] = { enabled = false, icon = icons.diagnostics.Hint },
|
||||
},
|
||||
filetype = { enabled = true },
|
||||
preset = 'default',
|
||||
button = '×',
|
||||
current = { buffer_index = true },
|
||||
buffer_index = false,
|
||||
current = { buffer_index = false },
|
||||
},
|
||||
sidebar_filetypes = {
|
||||
-- Use the default values: {event = 'BufWinLeave', text = nil}
|
||||
NvimTree = true,
|
||||
-- Or, specify the text used for the offset:
|
||||
undotree = { text = 'undotree' },
|
||||
-- -- Or, specify the text used for the offset:
|
||||
-- undotree = { text = 'undotree' },
|
||||
-- Or, specify the event which the sidebar executes when leaving:
|
||||
['neo-tree'] = { event = 'BufWipeout' },
|
||||
-- ['neo-tree'] = { event = 'BufWipeout' },
|
||||
-- Or, specify both
|
||||
Outline = { event = 'BufWinLeave', text = 'symbols-outline' },
|
||||
-- Outline = { event = 'BufWinLeave', text = 'symbols-outline' },
|
||||
},
|
||||
maximum_padding = 2,
|
||||
no_name_title = '[✨X]',
|
||||
minimum_padding = 1,
|
||||
maximum_length = 20,
|
||||
no_name_title = '✨',
|
||||
semantic_letters = true,
|
||||
-- insert_at_start = true,
|
||||
-- …etc.
|
||||
},
|
||||
version = '^1.0.0', -- optional: only update when a new 1.x version is released
|
||||
},
|
||||
|
@ -224,14 +278,6 @@ return {
|
|||
})
|
||||
end,
|
||||
},
|
||||
-- {
|
||||
-- -- https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-base16.md#default-config
|
||||
-- 'echasnovski/mini.base16',
|
||||
-- config = function()
|
||||
-- local palette = require('mini.base16')
|
||||
-- palette.setup({ palette = palette.mini_palette('#001e1e', '#cccccc', 50) })
|
||||
-- end,
|
||||
-- },
|
||||
{
|
||||
-- https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-starter.md#default-config
|
||||
"echasnovski/mini.starter",
|
||||
|
@ -243,7 +289,15 @@ return {
|
|||
if vim.fn.executable('cfonts') == 1 then
|
||||
local cwd = vim.fn.getcwd()
|
||||
local phrase = string.match(cwd, '[/\\]([^/\\]+)$')
|
||||
local banner = vim.system({ 'cfonts', phrase }, { text = true }):wait().stdout
|
||||
local fonts = { 'chrome', 'block', 'tiny' }
|
||||
local figfonts = {'sblood', 'rounded'}
|
||||
local banner = phrase
|
||||
local cfonts_cmd = "cfonts " .. phrase .. " -f " .. fonts[1]
|
||||
local fig_cmd = 'figlet -W -f' .. figfonts[1] .. ' ' .. phrase
|
||||
local exe_expr = "!" .. cfonts_cmd
|
||||
-- banner = vim.system({ 'cfonts', phrase }, { text = true }):wait().stdout
|
||||
-- banner = vim.system({ 'cfonts', phrase, '-f', fonts[1] }, { text = true }):wait().stdout
|
||||
banner = vim.api.nvim_exec("execute '" .. exe_expr .. "'", { output = true })
|
||||
logo = table.concat({
|
||||
'Project: ',
|
||||
string.gsub(banner, "(\r?\n)%s*\r?\n", "%1"),
|
||||
|
@ -317,32 +371,6 @@ return {
|
|||
)
|
||||
end,
|
||||
},
|
||||
-- {
|
||||
-- -- https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-starter.md#default-config
|
||||
-- 'echasnovski/mini.starter',
|
||||
-- config = function()
|
||||
-- local pad = string.rep(" ", 22)
|
||||
-- local new_section = function(name, action, section)
|
||||
-- return { name = name, action = action, section = pad .. section }
|
||||
-- end
|
||||
-- local starter = require('mini.starter')
|
||||
-- starter.setup({
|
||||
-- -- items = {
|
||||
-- -- starter.sections.recent_files(5),
|
||||
-- -- -- starter.sections.sessions(3),
|
||||
-- -- new_section("Session restore", [[lua require("persistence").load()]], "Session"),
|
||||
-- -- starter.sections.builtin_actions(),
|
||||
-- -- starter.sections.telescope(),
|
||||
-- -- },
|
||||
-- content_hooks = {
|
||||
-- starter.gen_hook.adding_bullet(pad .. "░ ", false),
|
||||
-- starter.gen_hook.aligning("center", "center"),
|
||||
-- },
|
||||
-- evaluate_single = true,
|
||||
-- silent = true,
|
||||
-- })
|
||||
-- end,
|
||||
-- },
|
||||
{
|
||||
-- Set lualine as statusline
|
||||
'nvim-lualine/lualine.nvim',
|
||||
|
@ -370,4 +398,41 @@ return {
|
|||
end,
|
||||
},
|
||||
},
|
||||
{
|
||||
-- https://github.com/ellisonleao/glow.nvim#setup
|
||||
"ellisonleao/glow.nvim",
|
||||
dependencies = {
|
||||
{
|
||||
-- https://github.com/richardbizik/nvim-toc#configuration
|
||||
'richardbizik/nvim-toc',
|
||||
-- config = true,
|
||||
ft = { 'markdown' },
|
||||
init = function()
|
||||
vim.api.nvim_create_autocmd(
|
||||
"BufEnter",
|
||||
{
|
||||
pattern = "*.md,*.markdown",
|
||||
callback = function()
|
||||
-- create command to generate table of contents for markdown files at current cursor position
|
||||
vim.api.nvim_buf_create_user_command(0, 'TOC',
|
||||
function()
|
||||
local toc = require('nvim-toc').generate_md_toc()
|
||||
local line = vim.api.nvim_win_get_cursor(0)[1]
|
||||
vim.api.nvim_buf_set_lines(0, line, line, true, toc)
|
||||
end,
|
||||
{ nargs = 0 }
|
||||
)
|
||||
end
|
||||
}
|
||||
)
|
||||
end,
|
||||
},
|
||||
},
|
||||
opts = {
|
||||
border = vim.g.pref_border_style,
|
||||
style = 'dark',
|
||||
},
|
||||
config = true,
|
||||
cmd = "Glow",
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,32 +1,65 @@
|
|||
local icons = require('custom.helpers.icons')
|
||||
|
||||
return {
|
||||
{ 'tpope/vim-fugitive' },
|
||||
{ 'tpope/vim-rhubarb' },
|
||||
{
|
||||
'f-person/git-blame.nvim',
|
||||
opts = {
|
||||
-- https://github.com/f-person/git-blame.nvim#configuration
|
||||
enabled = true,
|
||||
date_format = '%r',
|
||||
virtual_text_column = vim.o.textwidth,
|
||||
delay = 500,
|
||||
message_template = ' ✎ <author> • <date> • <summary> • <sha>',
|
||||
message_when_not_committed = ' ✎ Not committed yet'
|
||||
},
|
||||
-- https://github.com/sindrets/diffview.nvim#configuration
|
||||
'sindrets/diffview.nvim',
|
||||
config = true,
|
||||
},
|
||||
-- {
|
||||
-- 'f-person/git-blame.nvim',
|
||||
-- opts = {
|
||||
-- -- https://github.com/f-person/git-blame.nvim#configuration
|
||||
-- enabled = true,
|
||||
-- date_format = '%r',
|
||||
-- virtual_text_column = vim.o.textwidth,
|
||||
-- delay = 500,
|
||||
-- message_template = ' ✎ <author> • <date> • <summary> • <sha>',
|
||||
-- message_when_not_committed = ' ✎ Not committed yet'
|
||||
-- },
|
||||
-- config = true,
|
||||
-- },
|
||||
{
|
||||
-- https://github.com/lewis6991/gitsigns.nvim#installation--usage
|
||||
-- Adds git related signs to the gutter, as well as utilities for managing changes
|
||||
'lewis6991/gitsigns.nvim',
|
||||
enabled = false,
|
||||
dependencies = { 'nvim-tree/nvim-web-devicons' },
|
||||
opts = {
|
||||
-- See `:help gitsigns.txt`
|
||||
-- signs = {
|
||||
-- add = { text = icons.git.added },
|
||||
-- change = { text = icons.git.modified },
|
||||
-- delete = { text = icons.git.removed },
|
||||
-- changedelete = { text = icons.git.modified },
|
||||
-- },
|
||||
signs = {
|
||||
add = { text = '+' },
|
||||
change = { text = '~' },
|
||||
change = { text = '△' },
|
||||
-- changedelete = { text = '△' },
|
||||
changedelete = { text = '⌦' },
|
||||
delete = { text = '_' },
|
||||
topdelete = { text = '‾' },
|
||||
changedelete = { text = '~' },
|
||||
-- untracked = { text = '' },
|
||||
},
|
||||
signcolumn = true,
|
||||
numhl = false,
|
||||
linehl = false,
|
||||
word_diff = false,
|
||||
current_line_blame = true,
|
||||
current_line_blame_opts = {
|
||||
-- virt_text_pos = 'right_align',
|
||||
ignore_whitespace = true,
|
||||
delay = 500,
|
||||
},
|
||||
current_line_blame_formatter_opts = {
|
||||
relative_time = true,
|
||||
},
|
||||
attach_to_untracked = false,
|
||||
-- https://create.roblox.com/docs/reference/engine/libraries/os#date
|
||||
current_line_blame_formatter = ' ✎ <author>, <author_time:%R> (<author_time:%b %d, %Y>) - <summary>',
|
||||
-- sign_priority = 100,
|
||||
on_attach = function(bufnr)
|
||||
vim.keymap.set('n', '<leader>gp', require('gitsigns').prev_hunk,
|
||||
{ buffer = bufnr, desc = '[G]o to [P]revious Hunk' })
|
||||
|
@ -34,5 +67,6 @@ return {
|
|||
vim.keymap.set('n', '<leader>ph', require('gitsigns').preview_hunk, { buffer = bufnr, desc = '[P]review [H]unk' })
|
||||
end,
|
||||
},
|
||||
config = true,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
local builtin = require "telescope.builtin"
|
||||
local api = vim.api
|
||||
local command = api.nvim_create_user_command
|
||||
local brackets = {
|
||||
['('] = ')',
|
||||
['{'] = '}',
|
||||
['['] = ']',
|
||||
['<'] = '>',
|
||||
}
|
||||
|
||||
command('UpdateAll', function()
|
||||
vim.cmd([[bufdo update]])
|
||||
end, { desc = "Save all unsaved buffers/files" })
|
||||
|
||||
-- auto surround word under cursor
|
||||
function wrap_symbol(opts)
|
||||
local args = opts.fargs;
|
||||
local current_symbol = vim.call('expand', '<cword>')
|
||||
local start_char = args[1]
|
||||
if not start_char then
|
||||
-- exit without changing the buffer
|
||||
return
|
||||
end
|
||||
|
||||
local close_char = brackets[start_char] or start_char
|
||||
vim.cmd("normal! diwi" .. start_char .. current_symbol .. close_char)
|
||||
end
|
||||
|
||||
command('WrapSymbol', wrap_symbol, { nargs = "?", desc = "Wrap symbol under cursor in a character" })
|
||||
|
||||
-- [[ Reload neovim config ]]
|
||||
-- Inspired by https://stackoverflow.com/a/72504767
|
||||
function reload_config()
|
||||
-- TODO: Get this path dynamically.
|
||||
local config_path = "~/.config/nvim/init.lua"
|
||||
for name, _ in pairs(package.loaded) do
|
||||
if name:match('^user') and not name:match('nvim-tree') then
|
||||
package.loaded[name] = nil
|
||||
end
|
||||
end
|
||||
vim.cmd.luafile(config_path)
|
||||
vim.notify('Neovim config reloaded')
|
||||
end
|
||||
|
||||
command('ReloadConfig', reload_config, { desc = "Reload nvim config" })
|
|
@ -3,14 +3,18 @@
|
|||
-- Use your language server to automatically format your code on save.
|
||||
-- Adds additional commands as well to manage the behavior
|
||||
|
||||
local alt_format_cmd = [[Format]]
|
||||
|
||||
return {
|
||||
'neovim/nvim-lspconfig',
|
||||
config = function()
|
||||
init = function()
|
||||
-- Switch for controlling whether you want autoformatting.
|
||||
-- Use :KickstartFormatToggle to toggle autoformatting on or off
|
||||
local format_is_enabled = true
|
||||
-- Use :FormatToggle to toggle autoformatting on or off
|
||||
local format_is_enabled = vim.g.pref_autoformat or false
|
||||
|
||||
vim.api.nvim_create_user_command('FormatToggle', function()
|
||||
format_is_enabled = not format_is_enabled
|
||||
vim.g.pref_autoformat = format_is_enabled
|
||||
print('Setting autoformatting to: ' .. tostring(format_is_enabled))
|
||||
end, {})
|
||||
|
||||
|
@ -20,7 +24,7 @@ return {
|
|||
local _augroups = {}
|
||||
local get_augroup = function(client)
|
||||
if not _augroups[client.id] then
|
||||
local group_name = 'kickstart-lsp-format-' .. client.name
|
||||
local group_name = 'ks-lsp-format-' .. client.name
|
||||
local id = vim.api.nvim_create_augroup(group_name, { clear = true })
|
||||
_augroups[client.id] = id
|
||||
end
|
||||
|
@ -32,18 +36,13 @@ return {
|
|||
--
|
||||
-- See `:help LspAttach` for more information about this autocmd event.
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
group = vim.api.nvim_create_augroup('kickstart-lsp-attach-format', { clear = true }),
|
||||
group = vim.api.nvim_create_augroup('ks-lsp-attach-format', { clear = true }),
|
||||
-- This is where we attach the autoformatting for reasonable clients
|
||||
callback = function(args)
|
||||
local client_id = args.data.client_id
|
||||
local client = vim.lsp.get_client_by_id(client_id)
|
||||
local bufnr = args.buf
|
||||
|
||||
-- Only attach to clients that support document formatting
|
||||
if not client.server_capabilities.documentFormattingProvider then
|
||||
return
|
||||
end
|
||||
|
||||
-- Tsserver usually works poorly. Sorry you work with bad languages
|
||||
-- You can remove this line if you know what you're doing :)
|
||||
--
|
||||
|
@ -62,12 +61,20 @@ return {
|
|||
return
|
||||
end
|
||||
|
||||
vim.lsp.buf.format {
|
||||
-- Only attach to clients that support document formatting
|
||||
if not client.server_capabilities.documentFormattingProvider then
|
||||
vim.cmd(alt_format_cmd)
|
||||
return
|
||||
end
|
||||
|
||||
-- [[ TODO: Keep in sync with <Leader>cf ]]
|
||||
vim.lsp.buf.format({
|
||||
async = false,
|
||||
filter = function(c)
|
||||
return c.id == client.id
|
||||
end,
|
||||
}
|
||||
})
|
||||
vim.cmd(alt_format_cmd)
|
||||
end,
|
||||
})
|
||||
end,
|
||||
|
|
Loading…
Reference in New Issue