some improvements
This commit is contained in:
27
configs/nvim/lua/max/configs/gestures.lua
Normal file
27
configs/nvim/lua/max/configs/gestures.lua
Normal file
@@ -0,0 +1,27 @@
|
||||
local gesture = require("gesture")
|
||||
|
||||
vim.keymap.set("n", "<RightMouse>", [[<Nop>]])
|
||||
vim.keymap.set("n", "<RightDrag>", [[<Cmd>lua require("gesture").draw()<CR>]], { silent = true })
|
||||
vim.keymap.set("n", "<RightRelease>", [[<Cmd>lua require("gesture").finish()<CR>]], { silent = true })
|
||||
|
||||
gesture.register({
|
||||
name = "go back",
|
||||
inputs = { gesture.right() },
|
||||
-- map to `<C-o>` keycode
|
||||
action = [[lua vim.cmd('sp')]],
|
||||
})
|
||||
|
||||
|
||||
gesture.register({
|
||||
name = "go back",
|
||||
inputs = { gesture.down() },
|
||||
-- map to `<C-o>` keycode
|
||||
action = [[lua vim.cmd('vsp')]],
|
||||
})
|
||||
|
||||
-- gesture.register({
|
||||
-- name = "scroll to bottom",
|
||||
-- inputs = { gesture.right() },
|
||||
-- action = "normal! G",
|
||||
-- })
|
||||
|
@@ -4,24 +4,20 @@ if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local default_capabilities = {
|
||||
textDocument = {
|
||||
completion = {
|
||||
editsNearCursor = true,
|
||||
},
|
||||
},
|
||||
offsetEncoding = { 'utf-8', 'utf-16' },
|
||||
}
|
||||
local default_capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
default_capabilities.textDocument.completion = false
|
||||
default_capabilities.textDocument.synchronization.didSave = false;
|
||||
|
||||
local default_config = {
|
||||
cmd = { 'glslls' }, -- GLSL lsp executable from (https://github.com/svenstaro/glsl-language-server
|
||||
filetypes = { 'glsl' },
|
||||
filetypes = { 'glsl', 'vs', 'fs' },
|
||||
root_dir = util.root_pattern('compile_commands.json', '.git'),
|
||||
single_file_support = true,
|
||||
capabilities = default_capabilities,
|
||||
}
|
||||
|
||||
return {
|
||||
capabilities = default_capabilities,
|
||||
default_configs = default_config,
|
||||
commands = {},
|
||||
docs = {
|
||||
|
@@ -2,18 +2,17 @@ local mason = require("mason")
|
||||
local mason_lsp = require("mason-lspconfig")
|
||||
local lsp = require("lspconfig")
|
||||
|
||||
|
||||
require("null-ls").setup({
|
||||
sources = {
|
||||
require("null-ls").builtins.formatting.stylua,
|
||||
require("null-ls").builtins.diagnostics.eslint,
|
||||
-- require("null-ls").builtins.code_actions.eslint_d,
|
||||
-- require("null-ls").builtins.completion.spell,
|
||||
},
|
||||
})
|
||||
-- local null_ls = require("null-ls")
|
||||
-- null_ls.setup({
|
||||
-- sources = {
|
||||
-- -- null_ls.builtins.formatting.stylua,
|
||||
-- -- null_ls.builtins.code_actions.eslint_d,
|
||||
-- -- null_ls.builtins.formatting.prettierd
|
||||
-- -- require("null-ls").builtins.completion.spell,
|
||||
-- },
|
||||
-- })
|
||||
|
||||
mason.setup()
|
||||
|
||||
mason_lsp.setup({
|
||||
ensure_installed = { "sumneko_lua", "jsonls", "tsserver", "svelte", "cssls" },
|
||||
})
|
||||
@@ -23,6 +22,8 @@ table.insert(runtime_path, "lua/?.lua")
|
||||
table.insert(runtime_path, "lua/?/init.lua")
|
||||
|
||||
local function on_attach(client, bufnr)
|
||||
|
||||
|
||||
if client.supports_method("textDocument/formatting") then
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
buffer = bufnr,
|
||||
@@ -44,28 +45,24 @@ local function on_attach(client, bufnr)
|
||||
end,
|
||||
})
|
||||
else
|
||||
-- vim.notify("Lsp (" .. client.name .. ") doesnt support format")
|
||||
print("Lsp (" .. client.name .. ") doesnt support format")
|
||||
end
|
||||
end
|
||||
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
capabilities.textDocument.foldingRange = {
|
||||
dynamicRegistration = false,
|
||||
lineFoldingOnly = true
|
||||
lineFoldingOnly = true,
|
||||
}
|
||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||
|
||||
local custom_lsp = {};
|
||||
local custom_lsp = {}
|
||||
|
||||
custom_lsp.tsserver = {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
root_dir = lsp.util.root_pattern("tsconfig.json", "package.json", "jsconfig.json", ".git"),
|
||||
}
|
||||
|
||||
custom_lsp.sumneko_lua = {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
@@ -90,10 +87,7 @@ custom_lsp.sumneko_lua = {
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
custom_lsp.jsonls = {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
settings = {
|
||||
provideFormatter = false,
|
||||
json = {
|
||||
@@ -131,8 +125,6 @@ custom_lsp.jsonls = {
|
||||
}
|
||||
|
||||
custom_lsp.intelephense = {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
settings = {
|
||||
intelephense = {
|
||||
stubs = {
|
||||
@@ -152,7 +144,6 @@ custom_lsp.intelephense = {
|
||||
}
|
||||
|
||||
custom_lsp.rust_analyzer = {
|
||||
on_attach = on_attach,
|
||||
settings = {
|
||||
["rust-analyzer"] = {
|
||||
imports = {
|
||||
@@ -174,8 +165,6 @@ custom_lsp.rust_analyzer = {
|
||||
}
|
||||
|
||||
custom_lsp.yamlls = {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
settings = {
|
||||
yaml = {
|
||||
schemas = {
|
||||
@@ -188,11 +177,11 @@ custom_lsp.yamlls = {
|
||||
},
|
||||
}
|
||||
|
||||
custom_lsp.glslls = require("max.configs.lsp-glsl")
|
||||
-- local glslls_config = require("max.configs.lsp-glsl")
|
||||
-- glslls_config.on_attach = on_attach;
|
||||
-- lsp.glslls.setup(glslls_config)
|
||||
|
||||
custom_lsp.ltex = {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
settings = {
|
||||
ltex = {
|
||||
language = "de",
|
||||
@@ -209,15 +198,19 @@ custom_lsp.ltex = {
|
||||
},
|
||||
}
|
||||
|
||||
require('mason-lspconfig').setup_handlers({
|
||||
mason_lsp.setup_handlers({
|
||||
function(server_name)
|
||||
local config = {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
||||
if custom_lsp[server_name] ~= nil then
|
||||
lsp[server_name].setup(custom_lsp[server_name])
|
||||
else
|
||||
lsp[server_name].setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
})
|
||||
for k, v in pairs(custom_lsp[server_name]) do
|
||||
config[k] = v
|
||||
end
|
||||
end
|
||||
|
||||
lsp[server_name].setup(config)
|
||||
end,
|
||||
})
|
||||
|
@@ -225,6 +225,7 @@ ins_right({
|
||||
})
|
||||
|
||||
-- Text Progress
|
||||
|
||||
ins_right({
|
||||
"progress",
|
||||
padding = { right = 1 },
|
||||
|
@@ -66,5 +66,5 @@ local default = {
|
||||
}
|
||||
|
||||
telescope.setup(default)
|
||||
-- telescope.load_extension("git_worktree")
|
||||
telescope.load_extension("git_worktree")
|
||||
telescope.load_extension("notify")
|
||||
|
@@ -38,5 +38,5 @@ require("nvim-tree").setup({
|
||||
},
|
||||
})
|
||||
|
||||
vim.cmd("NvimTreeOpen")
|
||||
vim.api.nvim_input("<C-l>")
|
||||
-- vim.cmd("NvimTreeOpen")
|
||||
-- vim.api.nvim_input("<C-l>")
|
||||
|
@@ -2,6 +2,9 @@ require("nvim-treesitter.configs").setup({
|
||||
context_commentstring = {
|
||||
enable = true
|
||||
},
|
||||
autotag = {
|
||||
enable = true,
|
||||
},
|
||||
indent = {
|
||||
enable = true,
|
||||
},
|
||||
|
41
configs/nvim/lua/max/configs/ufo.lua
Normal file
41
configs/nvim/lua/max/configs/ufo.lua
Normal file
@@ -0,0 +1,41 @@
|
||||
return function()
|
||||
local handler = function(virtText, lnum, endLnum, width, truncate)
|
||||
local newVirtText = {}
|
||||
local suffix = (' %d '):format(endLnum - lnum)
|
||||
local sufWidth = vim.fn.strdisplaywidth(suffix)
|
||||
local targetWidth = width - sufWidth
|
||||
local curWidth = 0
|
||||
for _, chunk in ipairs(virtText) do
|
||||
local chunkText = chunk[1]
|
||||
local chunkWidth = vim.fn.strdisplaywidth(chunkText)
|
||||
if targetWidth > curWidth + chunkWidth then
|
||||
table.insert(newVirtText, chunk)
|
||||
else
|
||||
chunkText = truncate(chunkText, targetWidth - curWidth)
|
||||
local hlGroup = chunk[2]
|
||||
table.insert(newVirtText, { chunkText, hlGroup })
|
||||
chunkWidth = vim.fn.strdisplaywidth(chunkText)
|
||||
-- str width returned from truncate() may less than 2nd argument, need padding
|
||||
if curWidth + chunkWidth < targetWidth then
|
||||
suffix = suffix .. (' '):rep(targetWidth - curWidth - chunkWidth)
|
||||
end
|
||||
break
|
||||
end
|
||||
curWidth = curWidth + chunkWidth
|
||||
end
|
||||
table.insert(newVirtText, { suffix, 'MoreMsg' })
|
||||
return newVirtText
|
||||
end
|
||||
|
||||
require("ufo").setup({
|
||||
fold_virt_text_handler = handler,
|
||||
provider_selector = function(bufnr, filetype, buftype)
|
||||
return { 'treesitter', 'indent' }
|
||||
end
|
||||
})
|
||||
|
||||
vim.o.foldcolumn = '1'
|
||||
vim.o.foldlevel = 99
|
||||
vim.o.foldlevelstart = 99
|
||||
vim.o.foldenable = true
|
||||
end
|
@@ -33,14 +33,17 @@ autocmd("BufWinEnter", {
|
||||
group = save_fold,
|
||||
})
|
||||
|
||||
require("max.theme.statuscolumn");
|
||||
|
||||
autocmd({ "BufWinEnter","BufAdd" }, {
|
||||
desc = 'hide statuscolumn in nvimtree',
|
||||
group = vim.api.nvim_create_augroup('hide_nvimtree_stc', { clear = true }),
|
||||
callback = function(opts)
|
||||
if vim.bo[opts.buf].filetype == 'NvimTree' then
|
||||
vim.o.statuscolumn = ''
|
||||
vim.opt.statuscolumn = ''
|
||||
else
|
||||
vim.o.statuscolumn = '%=%r%s%#FoldColumn#%{foldlevel(v:lnum) > foldlevel(v:lnum - 1) ? (foldclosed(v:lnum) == -1 ? "" : "") : " " } %*'
|
||||
-- vim.o.statuscolumn = '%=%r%s%#FoldColumn#%{foldlevel(v:lnum) > foldlevel(v:lnum - 1) ? (foldclosed(v:lnum) == -1 ? "" : "") : " " } %*'
|
||||
vim.opt.statuscolumn = [[%!v:lua.Status.column()]]
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
@@ -35,9 +35,12 @@ map("n", "<Leader>ii", ":Lspsaga incomming_calls<CR>", opts)
|
||||
map("n", "<Leader>io", ":Lspsaga outgoing_calls<CR>", opts)
|
||||
map("n", "<Leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
||||
map({ "n", "v" }, "<Leader>c", "<cmd>Lspsaga code_action<CR>", { silent = true })
|
||||
map({ "n", "v" }, "<Leader>c", "<cmd>lua vim.lsp.buf.code_action()<CR>", { silent = true })
|
||||
map({ "n", "v" }, "gr", "<cmd>Lspsaga lsp_finder<CR>", opts)
|
||||
|
||||
map("n", "<Leader>u", ":UndotreeToggle<CR>", opts)
|
||||
map("n", "<Leader>wq", ":wqall!<CR>", opts)
|
||||
map("n", "<Leader>li", ":LspInfo<CR>", opts)
|
||||
|
||||
-- This is my [i]nspect section, [i]nspect [s]ymbols
|
||||
map("n", "<Leader>is", "<cmd>SymbolsOutline<cr>", opts)
|
||||
@@ -95,7 +98,6 @@ map("n", "<leader>m", ":Mason<CR>", opts);
|
||||
map("n", "<leader>l", ":Lazy<CR>", opts);
|
||||
map("n", "<leader>so", ":so %<CR>", opts);
|
||||
|
||||
|
||||
-- Faster git merge
|
||||
map("n", "<Leader>gd", ":Gvdiffsplit!<CR>", opts)
|
||||
map("n", "<Leader>gdl", ":diffget //3<CR>", opts)
|
||||
|
@@ -2,15 +2,18 @@ local plugins = {
|
||||
|
||||
"nvim-lua/plenary.nvim",
|
||||
|
||||
|
||||
|
||||
---------------------
|
||||
-- Theming Section --
|
||||
---------------------
|
||||
|
||||
"rktjmp/fwatch.nvim", -- d to check dark/light theme
|
||||
{ "catppuccin/nvim", name = "catppuccin", priority = 1000, lazy = false },
|
||||
|
||||
-- local plugins need to be explicitly configured with dir
|
||||
{
|
||||
dir = "~/Projects/sudoku.nvim",
|
||||
cmd = "Sudoku",
|
||||
config = true,
|
||||
},
|
||||
{
|
||||
"nvim-lualine/lualine.nvim",
|
||||
lazy = false,
|
||||
@@ -26,7 +29,7 @@ local plugins = {
|
||||
{
|
||||
"stevearc/dressing.nvim",
|
||||
event = "VeryLazy",
|
||||
config = true
|
||||
config = true,
|
||||
},
|
||||
{
|
||||
"folke/which-key.nvim",
|
||||
@@ -68,18 +71,16 @@ local plugins = {
|
||||
end,
|
||||
event = "VimEnter",
|
||||
},
|
||||
{
|
||||
"folke/neodev.nvim",
|
||||
lazy = false,
|
||||
config = true,
|
||||
},
|
||||
{
|
||||
"kevinhwang91/nvim-ufo",
|
||||
event = "BufReadPost",
|
||||
dependencies = 'kevinhwang91/promise-async',
|
||||
config = function()
|
||||
require("ufo").setup()
|
||||
|
||||
vim.o.foldcolumn = '1'
|
||||
vim.o.foldlevel = 99
|
||||
vim.o.foldlevelstart = 99
|
||||
vim.o.foldenable = true
|
||||
end,
|
||||
dependencies = "kevinhwang91/promise-async",
|
||||
config = require("max.configs.ufo"),
|
||||
},
|
||||
{
|
||||
"kyazdani42/nvim-tree.lua",
|
||||
@@ -98,6 +99,13 @@ local plugins = {
|
||||
require("max.configs.dashboard")
|
||||
end,
|
||||
}, -- startup screen
|
||||
{
|
||||
"notomo/gesture.nvim",
|
||||
lazy = false,
|
||||
config = function()
|
||||
require("max.configs.gestures")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"numToStr/Comment.nvim",
|
||||
event = "InsertEnter",
|
||||
@@ -127,15 +135,15 @@ local plugins = {
|
||||
-- Lsp Setup --
|
||||
---------------
|
||||
{
|
||||
'glepnir/lspsaga.nvim',
|
||||
event = 'BufRead',
|
||||
"glepnir/lspsaga.nvim",
|
||||
event = "BufRead",
|
||||
config = function()
|
||||
require('lspsaga').setup({
|
||||
require("lspsaga").setup({
|
||||
symbol_in_winbar = {
|
||||
enable = false,
|
||||
},
|
||||
})
|
||||
end
|
||||
end,
|
||||
},
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
@@ -150,7 +158,7 @@ local plugins = {
|
||||
event = "InsertEnter",
|
||||
config = function()
|
||||
require("max.configs.lsp")
|
||||
end
|
||||
end,
|
||||
},
|
||||
{
|
||||
"folke/trouble.nvim",
|
||||
@@ -182,7 +190,7 @@ local plugins = {
|
||||
},
|
||||
config = function()
|
||||
require("max.configs.autocomplete")
|
||||
end
|
||||
end,
|
||||
},
|
||||
{
|
||||
"nat-418/boole.nvim",
|
||||
@@ -201,26 +209,46 @@ local plugins = {
|
||||
-------------------------
|
||||
-- Syntax Highlighting --
|
||||
-------------------------
|
||||
{
|
||||
"norcalli/nvim-colorizer.lua",
|
||||
config = true,
|
||||
event = "VeryLazy",
|
||||
},
|
||||
{
|
||||
"folke/todo-comments.nvim",
|
||||
config = true,
|
||||
event = "VeryLazy",
|
||||
},
|
||||
{
|
||||
"styled-components/vim-styled-components",
|
||||
lazy = false,
|
||||
},
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
event = "VeryLazy",
|
||||
dependencies = {
|
||||
"nvim-treesitter/nvim-treesitter-textobjects",
|
||||
"JoosepAlviste/nvim-ts-context-commentstring"
|
||||
"JoosepAlviste/nvim-ts-context-commentstring",
|
||||
"windwp/nvim-ts-autotag",
|
||||
},
|
||||
config = function()
|
||||
require("max.configs.treesitter")
|
||||
end,
|
||||
run = ":TSUpdate",
|
||||
build = ":TSUpdate",
|
||||
},
|
||||
{
|
||||
'ckolkey/ts-node-action',
|
||||
dependencies = { 'nvim-treesitter' },
|
||||
"ckolkey/ts-node-action",
|
||||
dependencies = { "nvim-treesitter" },
|
||||
opts = {},
|
||||
},
|
||||
--------------------
|
||||
-- IDE Type Stuff --
|
||||
--------------------
|
||||
{
|
||||
"ThePrimeagen/git-worktree.nvim",
|
||||
config = true,
|
||||
event = "VeryLazy"
|
||||
},
|
||||
{
|
||||
"jackMort/ChatGPT.nvim",
|
||||
cmd = "ChatGPT",
|
||||
@@ -254,7 +282,7 @@ local plugins = {
|
||||
config = function()
|
||||
require("max.configs.sniprun")
|
||||
end,
|
||||
run = "bash ./install.sh",
|
||||
build = "bash ./install.sh",
|
||||
},
|
||||
{
|
||||
"uga-rosa/translate.nvim",
|
||||
|
32
configs/nvim/lua/max/theme/statuscolumn.lua
Normal file
32
configs/nvim/lua/max/theme/statuscolumn.lua
Normal file
@@ -0,0 +1,32 @@
|
||||
local M = {}
|
||||
_G.Status = M
|
||||
|
||||
---@return {name:string, text:string, texthl:string}[]
|
||||
function M.get_signs()
|
||||
local buf = vim.api.nvim_win_get_buf(vim.g.statusline_winid)
|
||||
return vim.tbl_map(function(sign)
|
||||
return vim.fn.sign_getdefined(sign.name)[1]
|
||||
end, vim.fn.sign_getplaced(buf, { group = "*", lnum = vim.v.lnum })[1].signs)
|
||||
end
|
||||
|
||||
function M.column()
|
||||
local sign, git_sign
|
||||
for _, s in ipairs(M.get_signs()) do
|
||||
if s.name:find("GitSign") then
|
||||
git_sign = s
|
||||
else
|
||||
sign = s
|
||||
end
|
||||
end
|
||||
local components = {
|
||||
sign and ("%#" .. sign.texthl .. "#" .. sign.text .. "%*") or " ",
|
||||
[[%=]],
|
||||
[[%{&nu?(&rnu&&v:relnum?v:relnum:v:lnum):''} ]],
|
||||
git_sign and ("%#" .. git_sign.texthl .. "#" .. git_sign.text .. "%*") or " ",
|
||||
}
|
||||
return table.concat(components, "")
|
||||
end
|
||||
|
||||
vim.opt.statuscolumn = [[%!v:lua.Status.column()]]
|
||||
|
||||
return M
|
@@ -2,22 +2,22 @@ local M = {}
|
||||
local cmd = vim.cmd
|
||||
|
||||
function M.create_augroup(autocmds, name)
|
||||
cmd("augroup " .. name)
|
||||
cmd("autocmd!")
|
||||
for _, autocmd in ipairs(autocmds) do
|
||||
cmd("autocmd " .. table.concat(autocmd, " "))
|
||||
end
|
||||
cmd("augroup END")
|
||||
cmd("augroup " .. name)
|
||||
cmd("autocmd!")
|
||||
for _, autocmd in ipairs(autocmds) do
|
||||
cmd("autocmd " .. table.concat(autocmd, " "))
|
||||
end
|
||||
cmd("augroup END")
|
||||
end
|
||||
|
||||
function M.ReloadConfig()
|
||||
for name, _ in pairs(package.loaded) do
|
||||
if name:match("^cnull") then
|
||||
package.loaded[name] = nil
|
||||
end
|
||||
for name, _ in pairs(package.loaded) do
|
||||
if name:match("^cnull") then
|
||||
package.loaded[name] = nil
|
||||
end
|
||||
end
|
||||
|
||||
dofile(vim.env.MYVIMRC)
|
||||
dofile(vim.env.MYVIMRC)
|
||||
end
|
||||
|
||||
local inspect = require("inspect")
|
||||
@@ -27,8 +27,8 @@ function M.dump(o)
|
||||
end
|
||||
|
||||
function M.has_plugin(pluginName)
|
||||
local status = pcall(require, pluginName)
|
||||
return status
|
||||
local status = pcall(require, pluginName)
|
||||
return status
|
||||
end
|
||||
|
||||
return M
|
||||
|
Reference in New Issue
Block a user