migration
This commit is contained in:
21
nvim/README.md
Normal file
21
nvim/README.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# Neovim
|
||||
|
||||
## Common Commands
|
||||
|
||||
Normal Mode:
|
||||
- `<leader>S` : search and replace with nvim spectre, it checks from your current directory
|
||||
- `K`: check type
|
||||
- `<leader>ca` : code action
|
||||
- `<leader>fg` : live grep from currently dir
|
||||
|
||||
## Debugging
|
||||
|
||||
- vim print in nvim:
|
||||
`lua vim.print(vim.lsp.get_active_clients({name = 'pyright'})[1])`
|
||||
|
||||
## Server Setup Schemas
|
||||
- Go into vim, type :Mason, open a language server with enter, then open it's schema with enter again
|
||||
|
||||
## TODO
|
||||
- figure out better formatting and linting solution
|
||||
- clean up settings and remap
|
||||
896
nvim/init.lua
Normal file
896
nvim/init.lua
Normal file
@@ -0,0 +1,896 @@
|
||||
-- non-plugin settings
|
||||
require("remap")
|
||||
require("settings")
|
||||
|
||||
-- lazy package manager setup
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not vim.loop.fs_stat(lazypath) then
|
||||
vim.fn.system({
|
||||
"git",
|
||||
"clone",
|
||||
"--filter=blob:none",
|
||||
"https://github.com/folke/lazy.nvim.git",
|
||||
"--branch=stable", -- latest stable release
|
||||
lazypath,
|
||||
})
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
require("lazy").setup({
|
||||
-- icons
|
||||
{ "nvim-tree/nvim-web-devicons", lazy = true },
|
||||
-- finder
|
||||
{
|
||||
"nvim-telescope/telescope.nvim",
|
||||
branch = 'master',
|
||||
-- tag = "0.1.5",
|
||||
dependencies = { "nvim-lua/plenary.nvim" },
|
||||
},
|
||||
-- looks
|
||||
{ "catppuccin/nvim", name = "catppuccin", priority = 1000 },
|
||||
{ "nvim-lualine/lualine.nvim" },
|
||||
{ "akinsho/bufferline.nvim", version = "*" },
|
||||
-- add indent lines
|
||||
{ "lukas-reineke/indent-blankline.nvim", main = "ibl", opts = {} },
|
||||
-- auto brackets
|
||||
{
|
||||
"windwp/nvim-autopairs",
|
||||
event = "InsertEnter",
|
||||
opts = {
|
||||
disable_filetype = { "TelescopePrompt" },
|
||||
}, -- this is equalent to setup({}) function
|
||||
},
|
||||
-- html auto tags
|
||||
-- https://github.com/windwp/nvim-ts-autotag
|
||||
{
|
||||
"windwp/nvim-ts-autotag",
|
||||
event = "InsertEnter",
|
||||
},
|
||||
-- commenter
|
||||
{
|
||||
"numToStr/Comment.nvim",
|
||||
opts = {
|
||||
toggler = { line = "<leader>cc" },
|
||||
opleader = { line = "<leader>cc" },
|
||||
},
|
||||
lazy = false,
|
||||
},
|
||||
-- search and replacer
|
||||
-- https://github.com/nvim-pack/nvim-spectre
|
||||
-- search and replace
|
||||
{
|
||||
"nvim-pack/nvim-spectre",
|
||||
event = "VeryLazy",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
},
|
||||
keys = {
|
||||
{
|
||||
"<leader>S",
|
||||
function()
|
||||
local root = vim.fs.root(0, { ".git" })
|
||||
require("spectre").open_visual({
|
||||
cwd = root or vim.fn.getcwd(),
|
||||
select_word = true,
|
||||
})
|
||||
end,
|
||||
desc = "Search current word at project root"
|
||||
},
|
||||
{
|
||||
"<leader>s",
|
||||
function()
|
||||
require("spectre").open_file_search({
|
||||
select_word = true,
|
||||
})
|
||||
end,
|
||||
desc = "Search on current file"
|
||||
},
|
||||
},
|
||||
opts = {
|
||||
default = {
|
||||
find = {
|
||||
cmd = "rg",
|
||||
options = { "case-sensitive", "word-regexp" } -- This makes rg case-sensitive
|
||||
},
|
||||
replace = {
|
||||
cmd = "sed"
|
||||
}
|
||||
},
|
||||
mapping = {
|
||||
['toggle_word_regexp'] = {
|
||||
map = "tw",
|
||||
cmd = "<cmd>lua require('spectre').change_options('word-regexp')<CR>",
|
||||
desc = "toggle word boundary"
|
||||
},
|
||||
['toggle_case_sensitive'] = {
|
||||
map = "tc",
|
||||
cmd = "<cmd>lua require('spectre').change_options('case-sensitive')<CR>",
|
||||
desc = "toggle case sensitive"
|
||||
},
|
||||
['toggle_ignore_case'] = {
|
||||
map = 'ti',
|
||||
cmd = "<cmd>lua require('spectre').change_options('ignore-case')<CR>",
|
||||
desc = 'toggle ignore case',
|
||||
},
|
||||
['toggle_ignore_hidden'] = {
|
||||
map = 'th',
|
||||
cmd = "<cmd>lua require('spectre').change_options('hidden')<CR>",
|
||||
desc = 'toggle search hidden',
|
||||
},
|
||||
},
|
||||
find_engine = {
|
||||
['rg'] = {
|
||||
cmd = 'rg',
|
||||
-- default args
|
||||
args = {
|
||||
'--color=never',
|
||||
'--no-heading',
|
||||
'--with-filename',
|
||||
'--line-number',
|
||||
'--column',
|
||||
},
|
||||
options = {
|
||||
['ignore-case'] = {
|
||||
value = '--ignore-case',
|
||||
icon = '[I]',
|
||||
desc = 'ignore case match',
|
||||
},
|
||||
['hidden'] = {
|
||||
value = '--hidden',
|
||||
desc = 'hidden file',
|
||||
icon = '[H]',
|
||||
},
|
||||
['word-regexp'] = {
|
||||
value = '-w',
|
||||
desc = 'match word only',
|
||||
icon = '[W]',
|
||||
},
|
||||
['case-sensitive'] = {
|
||||
value = '--case-sensitive',
|
||||
desc = 'case sensitive match',
|
||||
icon = '[C]',
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
-- syntax highlighter and stuff
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
build = ":TSUpdate",
|
||||
config = function()
|
||||
local configs = require("nvim-treesitter.configs")
|
||||
|
||||
configs.setup({
|
||||
ensure_installed = {
|
||||
"python",
|
||||
"lua",
|
||||
"vim",
|
||||
"javascript",
|
||||
"typescript",
|
||||
"html",
|
||||
"htmldjango",
|
||||
"toml",
|
||||
"tsx",
|
||||
"templ",
|
||||
"go",
|
||||
"astro"
|
||||
},
|
||||
sync_install = false,
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true },
|
||||
})
|
||||
end,
|
||||
},
|
||||
-- lsp
|
||||
-- https://github.com/neovim/nvim-lspconfig
|
||||
-- lsp package manager
|
||||
-- https://github.com/williamboman/mason-lspconfig.nvim
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"neovim/nvim-lspconfig",
|
||||
},
|
||||
-- completion
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
event = { "InsertEnter", "CmdlineEnter" },
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-path",
|
||||
"hrsh7th/cmp-cmdline",
|
||||
"hrsh7th/cmp-nvim-lsp-signature-help",
|
||||
},
|
||||
},
|
||||
-- completion snippets
|
||||
{
|
||||
"L3MON4D3/LuaSnip",
|
||||
event = { "InsertEnter", "CmdlineEnter" },
|
||||
dependencies = {
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
},
|
||||
},
|
||||
-- usage/references
|
||||
{
|
||||
'Wansmer/symbol-usage.nvim',
|
||||
event = 'BufReadPre', -- need run before LspAttach if you use nvim 0.9. On 0.10 use 'LspAttach'
|
||||
},
|
||||
-- errors visibility
|
||||
{
|
||||
"folke/trouble.nvim",
|
||||
opts = {}, -- for default options, refer to the configuration section for custom setup.
|
||||
cmd = "Trouble",
|
||||
keys = {
|
||||
{
|
||||
"<leader>xx",
|
||||
"<cmd>Trouble diagnostics toggle<cr>",
|
||||
desc = "Diagnostics (Trouble)",
|
||||
},
|
||||
{
|
||||
"<leader>xX",
|
||||
"<cmd>Trouble diagnostics toggle filter.buf=0<cr>",
|
||||
desc = "Buffer Diagnostics (Trouble)",
|
||||
},
|
||||
{
|
||||
"<leader>cs",
|
||||
"<cmd>Trouble symbols toggle focus=false<cr>",
|
||||
desc = "Symbols (Trouble)",
|
||||
},
|
||||
{
|
||||
"<leader>cl",
|
||||
"<cmd>Trouble lsp toggle focus=false win.position=right<cr>",
|
||||
desc = "LSP Definitions / references / ... (Trouble)",
|
||||
},
|
||||
{
|
||||
"<leader>xL",
|
||||
"<cmd>Trouble loclist toggle<cr>",
|
||||
desc = "Location List (Trouble)",
|
||||
},
|
||||
{
|
||||
"<leader>xQ",
|
||||
"<cmd>Trouble qflist toggle<cr>",
|
||||
desc = "Quickfix List (Trouble)",
|
||||
},
|
||||
},
|
||||
},
|
||||
-- formatter
|
||||
{
|
||||
"stevearc/conform.nvim",
|
||||
event = { "BufWritePre" },
|
||||
cmd = { "ConformInfo" },
|
||||
keys = {
|
||||
{
|
||||
-- Customize or remove this keymap to your liking
|
||||
"<leader>F",
|
||||
function()
|
||||
require("conform").format({ async = true, lsp_fallback = true })
|
||||
end,
|
||||
mode = "",
|
||||
desc = "Format buffer",
|
||||
},
|
||||
},
|
||||
opts = {
|
||||
formatters_by_ft = {
|
||||
lua = { "stylua" },
|
||||
sh = { "shfmt" },
|
||||
bash = { "shfmt" },
|
||||
python = { "isort", "black" },
|
||||
javascript = { "prettierd" },
|
||||
typescript = { "prettierd" },
|
||||
astro = { "prettierd" },
|
||||
html = { "prettierd" },
|
||||
css = { "prettierd" },
|
||||
json = { "prettierd" },
|
||||
jsonc = { "prettierd" },
|
||||
},
|
||||
},
|
||||
formatters = {
|
||||
prettierd_json = {
|
||||
command = vim.fn.stdpath("data") .. "~/.local/share/nvim/mason/bin/prettierd",
|
||||
args = {
|
||||
"--stdin-filepath", "$FILENAME",
|
||||
"--parser", "json",
|
||||
"--trailing-comma", "none"
|
||||
},
|
||||
stdin = true,
|
||||
},
|
||||
prettierd = {
|
||||
command = vim.fn.stdpath("data") .. "~/.local/share/nvim/mason/bin/prettierd",
|
||||
args = function(self, ctx)
|
||||
local args = { "--stdin-filepath", "$FILENAME" }
|
||||
|
||||
if vim.bo[ctx.buf].filetype == "jsonc" then
|
||||
table.insert(args, "--parser")
|
||||
table.insert(args, "json")
|
||||
table.insert(args, "--trailing-comma")
|
||||
table.insert(args, "none")
|
||||
end
|
||||
|
||||
return args
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
-- css color picker
|
||||
{
|
||||
"eero-lehtinen/oklch-color-picker.nvim",
|
||||
event = "VeryLazy",
|
||||
version = "*",
|
||||
keys = {
|
||||
-- One handed keymap recommended, you will be using the mouse
|
||||
{
|
||||
"<leader>v",
|
||||
function() require("oklch-color-picker").pick_under_cursor() end,
|
||||
desc = "Color pick under cursor",
|
||||
},
|
||||
},
|
||||
---@type oklch.Opts
|
||||
opts = {},
|
||||
},
|
||||
})
|
||||
-- end lazy package manager setup
|
||||
|
||||
-- usage hints formatter
|
||||
local function h(name) return vim.api.nvim_get_hl(0, { name = name }) end
|
||||
|
||||
-- hl-groups can have any name
|
||||
vim.api.nvim_set_hl(0, 'SymbolUsageRounding', { fg = h('CursorLine').bg, italic = true })
|
||||
vim.api.nvim_set_hl(0, 'SymbolUsageContent', { bg = h('CursorLine').bg, fg = h('Comment').fg, italic = true })
|
||||
vim.api.nvim_set_hl(0, 'SymbolUsageRef', { fg = h('Function').fg, bg = h('CursorLine').bg, italic = true })
|
||||
vim.api.nvim_set_hl(0, 'SymbolUsageDef', { fg = h('Type').fg, bg = h('CursorLine').bg, italic = true })
|
||||
vim.api.nvim_set_hl(0, 'SymbolUsageImpl', { fg = h('@keyword').fg, bg = h('CursorLine').bg, italic = true })
|
||||
|
||||
local function text_format(symbol)
|
||||
local res = {}
|
||||
|
||||
local round_start = { '', 'SymbolUsageRounding' }
|
||||
local round_end = { '', 'SymbolUsageRounding' }
|
||||
|
||||
-- Indicator that shows if there are any other symbols in the same line
|
||||
local stacked_functions_content = symbol.stacked_count > 0
|
||||
and ("+%s"):format(symbol.stacked_count)
|
||||
or ''
|
||||
|
||||
if symbol.references then
|
||||
local usage = symbol.references <= 1 and 'usage' or 'usages'
|
||||
local num = symbol.references == 0 and 'no' or symbol.references
|
||||
table.insert(res, round_start)
|
||||
table.insert(res, { ' ', 'SymbolUsageRef' })
|
||||
table.insert(res, { ('%s %s'):format(num, usage), 'SymbolUsageContent' })
|
||||
table.insert(res, round_end)
|
||||
end
|
||||
|
||||
if symbol.definition then
|
||||
if #res > 0 then
|
||||
table.insert(res, { ' ', 'NonText' })
|
||||
end
|
||||
table.insert(res, round_start)
|
||||
table.insert(res, { ' ', 'SymbolUsageDef' })
|
||||
table.insert(res, { symbol.definition .. ' defs', 'SymbolUsageContent' })
|
||||
table.insert(res, round_end)
|
||||
end
|
||||
|
||||
if symbol.implementation then
|
||||
if #res > 0 then
|
||||
table.insert(res, { ' ', 'NonText' })
|
||||
end
|
||||
table.insert(res, round_start)
|
||||
table.insert(res, { ' ', 'SymbolUsageImpl' })
|
||||
table.insert(res, { symbol.implementation .. ' impls', 'SymbolUsageContent' })
|
||||
table.insert(res, round_end)
|
||||
end
|
||||
|
||||
if stacked_functions_content ~= '' then
|
||||
if #res > 0 then
|
||||
table.insert(res, { ' ', 'NonText' })
|
||||
end
|
||||
table.insert(res, round_start)
|
||||
table.insert(res, { ' ', 'SymbolUsageImpl' })
|
||||
table.insert(res, { stacked_functions_content, 'SymbolUsageContent' })
|
||||
table.insert(res, round_end)
|
||||
end
|
||||
|
||||
return res
|
||||
end
|
||||
require('symbol-usage').setup({
|
||||
text_format = text_format,
|
||||
references = { enabled = true, include_declaration = false },
|
||||
definition = { enabled = true },
|
||||
kinds = {
|
||||
vim.lsp.protocol.SymbolKind.Function,
|
||||
vim.lsp.protocol.SymbolKind.Method,
|
||||
vim.lsp.protocol.SymbolKind.Constant,
|
||||
vim.lsp.protocol.SymbolKind.Struct, -- Add this for Go structs
|
||||
vim.lsp.protocol.SymbolKind.Interface, -- You might also want interfaces
|
||||
vim.lsp.protocol.SymbolKind.Class, -- Some languages use Class
|
||||
}
|
||||
})
|
||||
-- end usage hints formatter
|
||||
|
||||
-- lsp stuff
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)
|
||||
capabilities.offsetEncoding = { "utf-16", "utf-8" }
|
||||
require("mason").setup()
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = {
|
||||
"lua_ls",
|
||||
"bashls",
|
||||
-- "python-lsp-server",
|
||||
"astro",
|
||||
"tailwindcss",
|
||||
"ts_ls",
|
||||
"html",
|
||||
"pyright",
|
||||
"templ",
|
||||
"gopls",
|
||||
"emmet_ls", -- for cmp mainly, helps with auto quotes in html
|
||||
},
|
||||
automatic_installation = true,
|
||||
automatic_enable = false
|
||||
})
|
||||
-- Tailwind CSS
|
||||
vim.lsp.config('tailwindcss', {
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
tailwindCSS = {
|
||||
experimental = {
|
||||
-- this will capture any variable assignment in single/double quotes and encased in brackets as well
|
||||
classRegex = {
|
||||
"Css = (\\{[^\\{\\}]+\\}|\\[[^\\[\\]]+\\]|'[^']+'|\"[^\"]+\")",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
filetypes = { "htmldjango", "templ" },
|
||||
})
|
||||
vim.lsp.enable('tailwindcss')
|
||||
|
||||
-- Python
|
||||
vim.lsp.config('pyright', {
|
||||
capabilities = capabilities,
|
||||
})
|
||||
vim.lsp.enable('pyright')
|
||||
|
||||
-- Bash
|
||||
vim.lsp.config('bashls', {
|
||||
capabilities = capabilities,
|
||||
})
|
||||
vim.lsp.enable('bashls')
|
||||
|
||||
-- Astro
|
||||
vim.lsp.config('astro', {
|
||||
capabilities = capabilities,
|
||||
})
|
||||
vim.lsp.enable('astro')
|
||||
|
||||
-- Typescript
|
||||
vim.lsp.config('ts_ls', {
|
||||
capabilities = capabilities,
|
||||
})
|
||||
vim.lsp.enable('ts_ls')
|
||||
|
||||
-- Emmet
|
||||
vim.lsp.config('emmet_ls', {
|
||||
capabilities = capabilities,
|
||||
})
|
||||
vim.lsp.enable('emmet_ls')
|
||||
|
||||
-- HTML
|
||||
vim.lsp.config('html', {
|
||||
capabilities = capabilities,
|
||||
filetypes = { "htmldjango", "templ" },
|
||||
})
|
||||
vim.lsp.enable('html')
|
||||
|
||||
-- Templ
|
||||
vim.lsp.config('templ', {
|
||||
capabilities = capabilities,
|
||||
})
|
||||
vim.lsp.enable('templ')
|
||||
|
||||
-- Gopls
|
||||
vim.lsp.config('gopls', {
|
||||
capabilities = capabilities,
|
||||
-- settings = {
|
||||
-- gopls = {
|
||||
-- -- directoryFilters = { "-**/*_templ.go" },
|
||||
-- },
|
||||
-- },
|
||||
})
|
||||
vim.lsp.enable('gopls')
|
||||
|
||||
-- Lua LS
|
||||
vim.lsp.config('lua_ls', {
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { "vim" },
|
||||
},
|
||||
telemetry = { enable = false },
|
||||
workspace = { checkThirdParty = false },
|
||||
hint = { enable = true },
|
||||
},
|
||||
},
|
||||
})
|
||||
vim.lsp.enable('lua_ls')
|
||||
|
||||
local has_words_before = function()
|
||||
unpack = unpack or table.unpack
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||
end
|
||||
local function border(hl_name)
|
||||
return {
|
||||
{ "╭", hl_name },
|
||||
{ "─", hl_name },
|
||||
{ "╮", hl_name },
|
||||
{ "│", hl_name },
|
||||
{ "╯", hl_name },
|
||||
{ "─", hl_name },
|
||||
{ "╰", hl_name },
|
||||
{ "│", hl_name },
|
||||
}
|
||||
end
|
||||
local luasnip = require("luasnip")
|
||||
luasnip.add_snippets("all", {
|
||||
luasnip.s("html", {
|
||||
luasnip.t({
|
||||
"<!DOCTYPE html>",
|
||||
"<html lang=\"en\">",
|
||||
" <head>",
|
||||
" <meta charset=\"UTF-8\">",
|
||||
" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">",
|
||||
" <link href=\"css/app.css\" rel=\"stylesheet\">",
|
||||
" <title></title>",
|
||||
" </head>",
|
||||
" <body>",
|
||||
"",
|
||||
" </body>",
|
||||
"</html>"
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
local cmp = require("cmp")
|
||||
cmp.setup({
|
||||
window = {
|
||||
completion = {
|
||||
border = border("CmpBorder"),
|
||||
winhighlight = "Normal:CmpPmenu,CursorLine:PmenuSel,Search:None",
|
||||
},
|
||||
documentation = { border = border("CmpDocBorder") },
|
||||
},
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = {
|
||||
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<C-e>"] = cmp.mapping.abort(),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }), -- <CR> = enter key
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
},
|
||||
sources = {
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" },
|
||||
{ name = "buffer" },
|
||||
{ name = "nvim_lsp_signature_help" },
|
||||
{ name = "path" },
|
||||
},
|
||||
})
|
||||
|
||||
-- Global mappings.
|
||||
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||
-- ## lsp diagnostics
|
||||
-- virtual_text = inline diagnostics
|
||||
vim.diagnostic.config({ virtual_text = false })
|
||||
|
||||
-- apply global float border
|
||||
local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview
|
||||
function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...)
|
||||
opts = opts or {}
|
||||
opts.border = opts.border or border("FloatBorder")
|
||||
return orig_util_open_floating_preview(contents, syntax, opts, ...)
|
||||
end
|
||||
|
||||
-- show diagnostics on cursor hover
|
||||
vim.o.updatetime = 250
|
||||
-- vim.cmd(
|
||||
-- [[autocmd CursorHold,CursorHoldI * lua if not require("cmp").visible() then vim.diagnostic.open_float(nil, {focus=false}) end]]
|
||||
-- )
|
||||
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
|
||||
callback = function()
|
||||
-- Don't show diagnostic if completion menu is visible
|
||||
if require("cmp").visible() then
|
||||
return
|
||||
end
|
||||
|
||||
-- Don't show diagnostic if a hover/signature window is already open
|
||||
for _, win in ipairs(vim.api.nvim_list_wins()) do
|
||||
local config = vim.api.nvim_win_get_config(win)
|
||||
if config.relative ~= '' then
|
||||
local buf = vim.api.nvim_win_get_buf(win)
|
||||
local ft = vim.bo[buf].filetype
|
||||
-- Check if it's a hover window (usually has 'markdown' filetype)
|
||||
if ft == 'markdown' or config.focusable == true then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
vim.diagnostic.open_float(nil, { focus = false })
|
||||
end
|
||||
})
|
||||
-- ## end lsp diagnostics
|
||||
|
||||
-- override gopls qualified template definition jumping
|
||||
local function custom_go_to_definition()
|
||||
-- Early exit for non-Go/templ files
|
||||
local ft = vim.bo.filetype
|
||||
-- if ft == "python" then
|
||||
-- vim.lsp.buf.definition()
|
||||
-- return
|
||||
if ft ~= "go" and ft ~= "templ" then
|
||||
require('telescope.builtin').lsp_definitions()
|
||||
return
|
||||
end
|
||||
-- Early exit if no gopls client attached
|
||||
local clients = vim.lsp.get_clients({ bufnr = 0, name = "gopls" })
|
||||
if #clients == 0 then
|
||||
require('telescope.builtin').lsp_definitions()
|
||||
return
|
||||
end
|
||||
-- Use the gopls client for position encoding
|
||||
local gopls_client = clients[1]
|
||||
local params = vim.lsp.util.make_position_params(0, gopls_client.offset_encoding)
|
||||
vim.lsp.buf_request(0, 'textDocument/definition', params, function(err, result, ctx, config)
|
||||
if err or not result or vim.tbl_isempty(result) then
|
||||
require('telescope.builtin').lsp_definitions()
|
||||
return
|
||||
end
|
||||
-- Convert single result to array
|
||||
if result.uri then
|
||||
result = { result }
|
||||
end
|
||||
-- Quick check: do we have any _templ.go files in results?
|
||||
local has_templ_generated = false
|
||||
for _, location in ipairs(result) do
|
||||
local uri = location.uri or location.targetUri
|
||||
local filepath = vim.uri_to_fname(uri)
|
||||
if filepath:match("_templ%.go$") then
|
||||
has_templ_generated = true
|
||||
break
|
||||
end
|
||||
end
|
||||
-- If no generated templ files, use normal telescope
|
||||
if not has_templ_generated then
|
||||
require('telescope.builtin').lsp_definitions()
|
||||
return
|
||||
end
|
||||
-- Only do the heavy processing if we found generated files
|
||||
local word_under_cursor = vim.fn.expand('<cword>')
|
||||
local processed_results = {}
|
||||
for _, location in ipairs(result) do
|
||||
local uri = location.uri or location.targetUri
|
||||
local filepath = vim.uri_to_fname(uri)
|
||||
if filepath:match("_templ%.go$") then
|
||||
local templ_file = filepath:gsub("_templ%.go$", ".templ")
|
||||
if vim.fn.filereadable(templ_file) == 1 then
|
||||
-- Simple search for the symbol
|
||||
local cmd = string.format("grep -n 'templ %s\\|func %s' %s",
|
||||
word_under_cursor, word_under_cursor, vim.fn.shellescape(templ_file))
|
||||
local output = vim.fn.system(cmd)
|
||||
if vim.v.shell_error == 0 and output ~= "" then
|
||||
local lnum = output:match("^(%d+)")
|
||||
if lnum then
|
||||
table.insert(processed_results, {
|
||||
uri = vim.uri_from_fname(templ_file),
|
||||
range = {
|
||||
start = { line = tonumber(lnum) - 1, character = 0 },
|
||||
["end"] = { line = tonumber(lnum) - 1, character = 0 }
|
||||
}
|
||||
})
|
||||
end
|
||||
else
|
||||
-- Keep original if not found in templ
|
||||
table.insert(processed_results, location)
|
||||
end
|
||||
else
|
||||
table.insert(processed_results, location)
|
||||
end
|
||||
else
|
||||
table.insert(processed_results, location)
|
||||
end
|
||||
end
|
||||
local final_results = #processed_results > 0 and processed_results or result
|
||||
if #final_results == 1 then
|
||||
-- Use modern API instead of deprecated jump_to_location
|
||||
local location = final_results[1]
|
||||
local uri = location.uri or location.targetUri
|
||||
local range = location.range or location.targetRange
|
||||
-- Open the file
|
||||
vim.cmd('edit ' .. vim.fn.fnameescape(vim.uri_to_fname(uri)))
|
||||
-- Jump to position
|
||||
local row = range.start.line + 1
|
||||
local col = range.start.character + 1
|
||||
vim.api.nvim_win_set_cursor(0, { row, col - 1 })
|
||||
-- Center the view
|
||||
vim.cmd('normal! zz')
|
||||
else
|
||||
local qf_items = {}
|
||||
for _, location in ipairs(final_results) do
|
||||
local filename = vim.uri_to_fname(location.uri or location.targetUri)
|
||||
local range = location.range or location.targetRange
|
||||
table.insert(qf_items, {
|
||||
filename = filename,
|
||||
lnum = range.start.line + 1,
|
||||
col = range.start.character + 1,
|
||||
text = "",
|
||||
})
|
||||
end
|
||||
vim.fn.setqflist(qf_items)
|
||||
require('telescope.builtin').quickfix()
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float)
|
||||
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev)
|
||||
vim.keymap.set("n", "]d", vim.diagnostic.goto_next)
|
||||
vim.keymap.set("n", "<leader>q", vim.diagnostic.setloclist)
|
||||
|
||||
-- auto on_attach on lspconfig server setup
|
||||
-- Use LspAttach autocommand to only map the following keys
|
||||
-- after the language server attaches to the current buffer
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
|
||||
callback = function(ev)
|
||||
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
if client.server_capabilities.completionProvider then
|
||||
vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc"
|
||||
end
|
||||
if client.server_capabilities.definitionProvider then
|
||||
vim.bo[ev.buf].tagfunc = "v:lua.vim.lsp.tagfunc"
|
||||
end
|
||||
|
||||
local opts = { noremap = true, silent = true, buffer = ev.buf }
|
||||
|
||||
-- Buffer local mappings.
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
|
||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
|
||||
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
|
||||
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts)
|
||||
vim.keymap.set("n", "<leader>wa", vim.lsp.buf.add_workspace_folder, opts)
|
||||
vim.keymap.set("n", "<leader>wr", vim.lsp.buf.remove_workspace_folder, opts)
|
||||
vim.keymap.set("n", "<leader>wl", function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, opts)
|
||||
vim.keymap.set("n", "<leader>D", vim.lsp.buf.type_definition, opts)
|
||||
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
|
||||
vim.keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts)
|
||||
vim.keymap.set("n", "gd", custom_go_to_definition, opts)
|
||||
vim.keymap.set("n", "gr", require('telescope.builtin').lsp_references, opts)
|
||||
end,
|
||||
})
|
||||
-- end lsp stuff
|
||||
|
||||
-- html auto tags
|
||||
require('nvim-ts-autotag').setup({
|
||||
aliases = {
|
||||
["astro"] = "html"
|
||||
}
|
||||
})
|
||||
-- end html auto tags
|
||||
|
||||
-- theme
|
||||
require("catppuccin").setup({
|
||||
compile_path = vim.fn.stdpath("cache") .. "/catppuccin",
|
||||
flavour = "macchiato",
|
||||
transparent_background = true,
|
||||
integrations = {
|
||||
cmp = true,
|
||||
treesitter = true,
|
||||
},
|
||||
telescope = {
|
||||
enabled = true,
|
||||
},
|
||||
})
|
||||
vim.cmd.colorscheme("catppuccin")
|
||||
-- end theme
|
||||
|
||||
-- bufferline
|
||||
require("bufferline").setup({
|
||||
options = { mode = "tabs", separator_style = "thin" },
|
||||
})
|
||||
vim.keymap.set("n", "<Tab>", "<Cmd>BufferLineCycleNext<CR>", {})
|
||||
vim.keymap.set("n", "<S-Tab>", "<Cmd>BufferLineCyclePrev<CR>", {})
|
||||
-- end bufferline
|
||||
|
||||
-- lualine
|
||||
require("lualine").setup({})
|
||||
-- end lualine
|
||||
|
||||
-- telescope
|
||||
require("telescope").setup({
|
||||
pickers = {
|
||||
find_files = {
|
||||
-- `hidden = true` will still show the inside of `.git/` as it's not `.gitignore`d.
|
||||
find_command = {
|
||||
"rg",
|
||||
"--files",
|
||||
'--no-heading',
|
||||
'--with-filename',
|
||||
'--line-number',
|
||||
'--column',
|
||||
"--glob", "!**/.git/*",
|
||||
-- "--hidden",
|
||||
},
|
||||
},
|
||||
live_grep = {
|
||||
additional_args = function()
|
||||
return {
|
||||
"--glob", "!**/.git/*",
|
||||
"--glob", "!**/go.sum",
|
||||
"--glob", "!**/go.mod",
|
||||
}
|
||||
end
|
||||
},
|
||||
lsp_definitions = {
|
||||
show_line = false,
|
||||
file_ignore_patterns = { ".*_templ.go" },
|
||||
theme = "dropdown",
|
||||
},
|
||||
lsp_references = {
|
||||
show_line = false,
|
||||
include_declaration = false,
|
||||
file_ignore_patterns = { ".*_templ.go" },
|
||||
theme = "dropdown",
|
||||
},
|
||||
},
|
||||
})
|
||||
local telescope_builtin = require("telescope.builtin")
|
||||
vim.keymap.set("n", "<leader>fg", telescope_builtin.live_grep, {})
|
||||
vim.keymap.set("n", "<leader>f", telescope_builtin.find_files, {})
|
||||
vim.keymap.set("n", "<C-f>", function()
|
||||
-- Handling error to output 1 line instead of several
|
||||
if pcall(telescope_builtin.git_files, { show_untracked = true }) then
|
||||
else
|
||||
print("Not a git project. Try running git init in root.")
|
||||
end
|
||||
end)
|
||||
-- end telescope
|
||||
|
||||
-- commenter
|
||||
local ft = require("Comment.ft")
|
||||
ft.set("typescriptreact", "{/* %s */}")
|
||||
ft.htmldjango = "{# %s #}"
|
||||
ft.templ = "// %s"
|
||||
-- end commenter
|
||||
27
nvim/lazy-lock.json
Normal file
27
nvim/lazy-lock.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" },
|
||||
"LuaSnip": { "branch": "master", "commit": "8ae1dedd988eb56441b7858bd1e8554dfadaa46d" },
|
||||
"bufferline.nvim": { "branch": "main", "commit": "6c456b888823d9e4832aa91c482bccd19445c009" },
|
||||
"catppuccin": { "branch": "main", "commit": "5e36ca599f4aa41bdd87fbf2c5aae4397ac55074" },
|
||||
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
|
||||
"cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" },
|
||||
"cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
|
||||
"cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "3d8912ebeb56e5ae08ef0906e3a54de1c66b92f1" },
|
||||
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
||||
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
|
||||
"conform.nvim": { "branch": "master", "commit": "c4b2efb8aee4af0ef179a9b49ba401de3c4ef5d2" },
|
||||
"indent-blankline.nvim": { "branch": "master", "commit": "3c8a185da4b8ab7aef487219f5e001b11d4b6aaf" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" },
|
||||
"lualine.nvim": { "branch": "master", "commit": "566b7036f717f3d676362742630518a47f132fff" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "56e435e09f8729af2d41973e81a0db440f8fe9c9" },
|
||||
"mason.nvim": { "branch": "main", "commit": "a09da6ac634926a299dd439da08bdb547a8ca011" },
|
||||
"nvim-autopairs": { "branch": "master", "commit": "9fd41181693dd4106b3e414a822bb6569924de81" },
|
||||
"nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "ce0e625df61be77abe1340fbc9afe9ad39b31dd8" },
|
||||
"nvim-spectre": { "branch": "master", "commit": "d8906855f1949ac97b1e77aaf8d3fe12ed158ddc" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "0da349ed303bea955942f409d29059cdb89dbe2c" },
|
||||
"nvim-ts-autotag": { "branch": "main", "commit": "8515e48a277a2f4947d91004d9aa92c29fdc5e18" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "3e24abe1ae66532135cec911562f553fe247cb56" },
|
||||
"plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" },
|
||||
"telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }
|
||||
}
|
||||
204
nvim/lua/remap.lua
Normal file
204
nvim/lua/remap.lua
Normal file
@@ -0,0 +1,204 @@
|
||||
vim.g.mapleader = " "
|
||||
|
||||
-- vim.cmd [[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]]
|
||||
-- Open project folder view
|
||||
vim.keymap.set('n', '<leader>E', '<cmd>:Ex<CR>')
|
||||
vim.keymap.set('n', '<leader>ER', '<cmd>:bw<CR>')
|
||||
-- Set current window as current root directory for searching
|
||||
vim.keymap.set("n", "<leader>sr", ":cd %:p:h<CR>")
|
||||
|
||||
-- Split window movement
|
||||
vim.keymap.set("n", "<A-Left>", "<C-w>h")
|
||||
vim.keymap.set("n", "<A-Down>", "<C-w>j")
|
||||
vim.keymap.set("n", "<A-Up>", "<C-w>k")
|
||||
vim.keymap.set("n", "<A-Right>", "<C-w>l")
|
||||
|
||||
-- netrw duplicate file, <leader>d
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = 'netrw',
|
||||
callback = function()
|
||||
vim.keymap.set('n', '<leader>d', function()
|
||||
-- Save current directory
|
||||
local original_dir = vim.fn.getcwd()
|
||||
|
||||
-- Change to the directory shown in netrw
|
||||
vim.cmd('lcd %:p:h')
|
||||
|
||||
-- Feed the keys with proper mode flag
|
||||
vim.api.nvim_feedkeys('mt', 'x', false)
|
||||
vim.api.nvim_feedkeys('mf', 'x', false)
|
||||
vim.api.nvim_feedkeys('mc', 'x', false)
|
||||
|
||||
-- Return to original directory after delay
|
||||
vim.defer_fn(function()
|
||||
vim.fn.chdir(original_dir)
|
||||
end, 500)
|
||||
end, { buffer = true, desc = 'Duplicate file in netrw' })
|
||||
end,
|
||||
})
|
||||
|
||||
-- Jump buffers movement
|
||||
local tab_buffer_histories = {}
|
||||
local is_navigating = false
|
||||
|
||||
local function get_current_tab_history()
|
||||
local tab = vim.fn.tabpagenr()
|
||||
if not tab_buffer_histories[tab] then
|
||||
tab_buffer_histories[tab] = {
|
||||
buffers = {},
|
||||
index = 1
|
||||
}
|
||||
end
|
||||
return tab_buffer_histories[tab]
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("BufEnter", {
|
||||
callback = function()
|
||||
if is_navigating then return end
|
||||
local buf = vim.fn.bufnr('%')
|
||||
if not vim.bo[buf].buflisted then return end
|
||||
local history = get_current_tab_history()
|
||||
|
||||
-- Remove any existing occurrence of this buffer from history
|
||||
for i = #history.buffers, 1, -1 do
|
||||
if history.buffers[i] == buf then
|
||||
table.remove(history.buffers, i)
|
||||
if i < history.index then
|
||||
history.index = history.index - 1
|
||||
elseif i == history.index then
|
||||
history.index = math.max(1, history.index - 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- If we're in the middle of history and switch to a new buffer,
|
||||
-- truncate future history
|
||||
if history.index < #history.buffers then
|
||||
for i = #history.buffers, history.index + 1, -1 do
|
||||
table.remove(history.buffers)
|
||||
end
|
||||
end
|
||||
|
||||
-- Add the buffer to history
|
||||
table.insert(history.buffers, buf)
|
||||
history.index = #history.buffers
|
||||
end
|
||||
})
|
||||
|
||||
vim.keymap.set("n", "<A-b>", function()
|
||||
local history = get_current_tab_history()
|
||||
if history.index > 1 then
|
||||
is_navigating = true
|
||||
history.index = history.index - 1
|
||||
local target_buf = history.buffers[history.index]
|
||||
|
||||
-- Check if buffer still exists and is valid
|
||||
if vim.fn.bufexists(target_buf) == 1 and vim.bo[target_buf].buflisted then
|
||||
vim.cmd('buffer ' .. target_buf)
|
||||
else
|
||||
-- Skip invalid buffers
|
||||
table.remove(history.buffers, history.index)
|
||||
history.index = math.max(1, history.index - 1)
|
||||
end
|
||||
|
||||
vim.schedule(function() is_navigating = false end)
|
||||
end
|
||||
end)
|
||||
|
||||
vim.keymap.set("n", "<A-n>", function()
|
||||
local history = get_current_tab_history()
|
||||
if history.index < #history.buffers then
|
||||
is_navigating = true
|
||||
history.index = history.index + 1
|
||||
local target_buf = history.buffers[history.index]
|
||||
|
||||
-- Check if buffer still exists and is valid
|
||||
if vim.fn.bufexists(target_buf) == 1 and vim.bo[target_buf].buflisted then
|
||||
vim.cmd('buffer ' .. target_buf)
|
||||
else
|
||||
-- Skip invalid buffers
|
||||
table.remove(history.buffers, history.index)
|
||||
history.index = math.min(#history.buffers, history.index)
|
||||
end
|
||||
|
||||
vim.schedule(function() is_navigating = false end)
|
||||
end
|
||||
end)
|
||||
|
||||
vim.keymap.set("n", "<A-c>", function()
|
||||
local current_buf = vim.fn.bufnr('%')
|
||||
local history = get_current_tab_history()
|
||||
history.buffers = { current_buf }
|
||||
history.index = 1
|
||||
print("Buffer history cleared")
|
||||
end)
|
||||
|
||||
vim.keymap.set("n", "<A-q>", function()
|
||||
local current_buf = vim.fn.bufnr('%')
|
||||
local history = get_current_tab_history()
|
||||
-- Remove current buffer from history
|
||||
for i = #history.buffers, 1, -1 do
|
||||
if history.buffers[i] == current_buf then
|
||||
table.remove(history.buffers, i)
|
||||
if i <= history.index then
|
||||
history.index = math.max(1, history.index - 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Navigate to previous buffer in history if available
|
||||
if #history.buffers > 0 and history.index <= #history.buffers then
|
||||
is_navigating = true
|
||||
vim.cmd('buffer ' .. history.buffers[history.index])
|
||||
vim.schedule(function() is_navigating = false end)
|
||||
end
|
||||
-- Delete the buffer
|
||||
vim.cmd('bd ' .. current_buf)
|
||||
end)
|
||||
|
||||
-- Clean up history when a tab is closed
|
||||
vim.api.nvim_create_autocmd("TabClosed", {
|
||||
callback = function()
|
||||
local closed_tab = tonumber(vim.fn.expand("<afile>"))
|
||||
if closed_tab then
|
||||
tab_buffer_histories[closed_tab] = nil
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
-- Makes shift+j not move cursor to the end
|
||||
vim.keymap.set("n", "J", "mzJ`z")
|
||||
-- collapse a tag with the cursor at the start of the tag
|
||||
vim.keymap.set("n", "<leader>j", "gJdw:j!<CR>", { silent = true })
|
||||
|
||||
-- nnoremap <silent> <C-l> :nohl<CR><C-l>
|
||||
-- vim.keymap.set("n", "<C-l>", vim.cmd(":nohl<CR><C-l>"))
|
||||
|
||||
-- Visual Mode: Move blocks of lines up or down
|
||||
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv'")
|
||||
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv'")
|
||||
|
||||
-- Autopairs sometimes wraps things, and sometimes doesnt
|
||||
-- This is for wrapping a word in a pair
|
||||
vim.keymap.set("n", "<leader>e{", "bcw{}<ESC>P")
|
||||
vim.keymap.set("n", "<leader>e[", "bcw[]<ESC>P")
|
||||
vim.keymap.set("n", "<leader>e<", "bcw<><ESC>P")
|
||||
vim.keymap.set("n", "<leader>e(", "bcw()<ESC>P")
|
||||
vim.keymap.set("n", "<leader>e'", "bcw''<ESC>P")
|
||||
vim.keymap.set("n", "<leader>e\"", "bcw\"\"<ESC>P")
|
||||
vim.keymap.set("n", "<leader>e`", "bcw``<ESC>P")
|
||||
|
||||
-- vertical movements
|
||||
-- center cursor after going up or down
|
||||
vim.keymap.set("n", "<C-d>", "<C-d>zz")
|
||||
vim.keymap.set("n", "<C-u>", "<C-u>zz")
|
||||
|
||||
|
||||
-- lsp restart
|
||||
vim.keymap.set('n', '<leader>l', function()
|
||||
vim.cmd('LspRestart')
|
||||
vim.defer_fn(function()
|
||||
-- Reload the plugin module
|
||||
package.loaded['symbol-usage'] = nil
|
||||
require('symbol-usage').refresh()
|
||||
end, 1000)
|
||||
end, { desc = 'Restart LSP and reload symbol-usage' })
|
||||
83
nvim/lua/settings.lua
Normal file
83
nvim/lua/settings.lua
Normal file
@@ -0,0 +1,83 @@
|
||||
-- leader timeout
|
||||
vim.opt.timeoutlen = 350
|
||||
-- Vim sets and globals
|
||||
vim.opt.wrap = true
|
||||
vim.opt.relativenumber = true
|
||||
vim.opt.mouse = "nvi"
|
||||
vim.opt.clipboard = "unnamedplus" -- Able to yank and paste crap from anywhere
|
||||
vim.opt.guicursor = "i-ci:ver30-iCursor-blinkwait300-blinkon200-blinkoff150"
|
||||
vim.opt.termguicolors = true
|
||||
vim.opt.encoding = "utf-8"
|
||||
vim.opt.cursorline = true -- Current line tracking
|
||||
vim.opt.number = true -- Current line number display
|
||||
|
||||
vim.opt.backup = false
|
||||
vim.opt.writebackup = false
|
||||
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
|
||||
vim.opt.undofile = true
|
||||
|
||||
vim.opt.updatetime = 50
|
||||
vim.opt.signcolumn = "no"
|
||||
vim.opt.scrolloff = 8
|
||||
|
||||
-- Indenting
|
||||
-- vim.opt.smartindent = true
|
||||
vim.opt.tabstop = 4
|
||||
vim.opt.softtabstop = 4
|
||||
vim.opt.shiftwidth = 4
|
||||
vim.opt.expandtab = true
|
||||
vim.api.nvim_create_autocmd({"FileType"}, {
|
||||
pattern = {"typescriptreact", "typescript", "javascript", "css", "html", "htmldjango", "yaml", "json", "md", "toml"},
|
||||
command = "setlocal shiftwidth=2 tabstop=2 softtabstop=2"
|
||||
})
|
||||
|
||||
vim.g.grepper = {tools = {"rg"}} -- This is for replace in project, ripgrep required
|
||||
vim.opt.wildignore:append{"*/node_modules/*", "*/venv/*"}
|
||||
vim.opt.path:append{"**"} -- find files down subfolders
|
||||
vim.g.python_host_prog = "/usr/bin/python2"
|
||||
vim.g.python3_host_prog = "/usr/bin/python3"
|
||||
|
||||
-- skeletons
|
||||
vim.cmd [[autocmd BufNewFile *.py 0r ~/.config/nvim/templates/skeleton.py]]
|
||||
vim.cmd [[autocmd BufNewFile *.sh 0r ~/.config/nvim/templates/skeleton.sh]]
|
||||
|
||||
-- filetypes
|
||||
vim.filetype.add({
|
||||
extension = {
|
||||
templ = "templ",
|
||||
},
|
||||
})
|
||||
|
||||
-- popout styling
|
||||
vim.api.nvim_create_autocmd("ColorScheme", {
|
||||
callback = function()
|
||||
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "FloatBorder", { bg = "none" })
|
||||
end,
|
||||
})
|
||||
vim.keymap.set('n', '<leader>x', function()
|
||||
vim.lsp.buf.clear_references()
|
||||
local win_ids = vim.fn.getwininfo()
|
||||
for _, win in pairs(win_ids) do
|
||||
if win.quickfix == 0 and win.loclist == 0 and win.terminal == 0 and win.tabnr == vim.fn.tabpagenr() then
|
||||
if vim.api.nvim_win_get_config(win.winid).relative ~= '' then
|
||||
vim.api.nvim_win_close(win.winid, false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end, { desc = "Close LSP floating windows" })
|
||||
|
||||
-- disable italics on conditionals
|
||||
vim.api.nvim_create_autocmd("ColorScheme", {
|
||||
pattern = "*",
|
||||
callback = function()
|
||||
-- Get all highlight groups and remove italic styling
|
||||
for _, group in ipairs(vim.fn.getcompletion("", "highlight")) do
|
||||
local hl = vim.api.nvim_get_hl(0, { name = group })
|
||||
if hl.italic then
|
||||
hl.italic = nil
|
||||
vim.api.nvim_set_hl(0, group, hl)
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
1
nvim/templates/skeleton.py
Normal file
1
nvim/templates/skeleton.py
Normal file
@@ -0,0 +1 @@
|
||||
#!/usr/bin/env python3
|
||||
1
nvim/templates/skeleton.sh
Normal file
1
nvim/templates/skeleton.sh
Normal file
@@ -0,0 +1 @@
|
||||
#!/bin/bash
|
||||
Reference in New Issue
Block a user