This commit is contained in:
sadan 2024-09-08 18:27:01 -04:00
parent bf42a74f00
commit ddf45b4e55
No known key found for this signature in database
7 changed files with 186 additions and 79 deletions

View file

@ -11,7 +11,11 @@ if not vim.loop.fs_stat(lazypath) then
}) })
end end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
if vim.g.vscode then
require"vscodePlugins"
else
require"plugins" require"plugins"
require"setup" require"setup"
require"keymap" require"keymap"
require"sets" require"sets"
end

View file

@ -2,7 +2,6 @@ local pkgs = {
"nixpkgs-fmt", "nixpkgs-fmt",
"jdtls", "jdtls",
"yaml-language-server", "yaml-language-server",
"eslint_d",
} }
local reg = require("mason-registry") local reg = require("mason-registry")
for _, pname in ipairs(pkgs) do for _, pname in ipairs(pkgs) do

View file

@ -1,4 +1,7 @@
local plugins = { local plugins = {
{
"christoomey/vim-titlecase"
},
{ {
"kylechui/nvim-surround", "kylechui/nvim-surround",
version = "*", -- Use for stability; omit to use `main` branch for the latest features version = "*", -- Use for stability; omit to use `main` branch for the latest features
@ -86,9 +89,9 @@ local plugins = {
{ {
"jose-elias-alvarez/null-ls.nvim", "jose-elias-alvarez/null-ls.nvim",
}, },
{ -- {
"MunifTanjim/eslint.nvim", -- "MunifTanjim/eslint.nvim",
}, -- },
{ {
"williamboman/mason.nvim", "williamboman/mason.nvim",
}, },

View file

@ -54,64 +54,39 @@ require("formatter").setup({
} }
end, end,
}, },
-- Formatter configurations for filetype "lua" go here -- -- THIS WILL ONLY BE USED WHEN NO LSP/PROJECT CONFIG IS USED
-- and will be executed in order
typescript = { typescript = {
require("formatter.filetypes.typescript").eslint_d, require("formatter.filetypes.typescript").prettier,
function()
return {
args = {
"--stdin",
"--fix-to-stdout",
},
exe = "eslint_d",
stdin = true,
try_node_modules = true,
}
end,
}, },
typescriptreact = { typescriptreact = {
require("formatter.filetypes.typescriptreact").eslint_d, require("formatter.filetypes.typescriptreact").prettier,
function()
return {
args = {
"--stdin",
"--fix-to-stdout",
},
exe = "eslint_d",
stdin = true,
try_node_modules = true,
}
end,
}, },
javascript = { -- javascript = {
require("formatter.filetypes.javascript").eslint_d, -- require("formatter.filetypes.javascript").eslint_d,
function () -- function()
return { -- return {
args = { -- cwd = "/home/meyer/src/estest",
"--stdin", -- args = {
"--fix-to-stdout", -- },
}, -- exe = "~/src/estest/test.sh",
exe = "eslint_d", -- stdin = true,
stdin = true, -- try_node_modules = false,
try_node_modules = true, -- }
} -- end,
end -- },
}, -- javascriptreact = {
javascriptreact = { -- require("formatter.filetypes.javascriptreact").eslint_d,
require("formatter.filetypes.javascriptreact").eslint_d, -- function()
function () -- return {
return { -- cwd = "/home/meyer/src/estest",
args = { -- args = {
"--stdin", -- },
"--fix-to-stdout", -- exe = "~/src/estest/test.sh",
}, -- stdin = true,
exe = "eslint_d", -- try_node_modules = false,
stdin = true, -- }
try_node_modules = true, -- end,
} -- },
end
},
cpp = { cpp = {
require("formatter.filetypes.c").clangformat, require("formatter.filetypes.c").clangformat,
function() function()

View file

@ -9,7 +9,42 @@ capabilities.textDocument.foldingRange = {
dynamicRegistration = false, dynamicRegistration = false,
lineFoldingOnly = true, lineFoldingOnly = true,
} }
local root_file = {
'.eslintrc',
'.eslintrc.js',
'.eslintrc.cjs',
'.eslintrc.yaml',
'.eslintrc.yml',
'.eslintrc.json',
'eslint.config.js',
'eslint.config.mjs',
'eslint.config.cjs',
'eslint.config.ts',
'eslint.config.mts',
'eslint.config.cts',
}
require"lspconfig".eslint.setup({
capabilities = capabilities,
-- root_dir = function (fname)
-- local rootDir = vim.fs.dirname(vim.fs.find({"package.json", "pnpm-lock.yaml", "node_modules"}, {upward = true})[1])
-- local eCode = os.execute([[bash -c "ls -alh -- ]].. rootDir ..[[ | grep --perl-regexp .eslintrc\..\{2,4\}\|eslint.config\..\{2,3\}"]])
-- -- if eCode ~= 0 then
-- -- print("funny")
-- -- return vim.fs.normalize("~/src/estest")
-- -- end
-- local util = require"lspconfig.util"
-- root_file = util.insert_package_json(root_file, 'eslintConfig', fname)
-- local a = util.root_pattern(unpack(root_file))(fname)
-- print(a)
-- return a
-- end,
-- fix format command on attach
on_attach = function (client, bufnr)
vim.keymap.set({"n"}, "<A-F>", "<cmd>EslintFixAll<cr>", {
buffer = bufnr,
})
end
})
-- jdtls -- jdtls
local function setupJDTLS() local function setupJDTLS()
local mason_registry = require("mason-registry") local mason_registry = require("mason-registry")
@ -109,7 +144,7 @@ end
-- }) -- })
-- ENDjdtls -- ENDjdtls
require("lspconfig").emmet_language_server.setup({ require("lspconfig").emmet_language_server.setup({
filetypes = {"css", "scss", "sass", "less", "html"} filetypes = {"css", "scss", "sass", "less", "html"},
capabilities = capabilities, capabilities = capabilities,
}) })
require("lspconfig").cssls.setup({ require("lspconfig").cssls.setup({
@ -243,22 +278,22 @@ require("setupclangdext")
require("null-ls").setup() require("null-ls").setup()
require("eslint").setup({ -- require("eslint").setup({
bin = "eslint_d", -- or `eslint` -- bin = "eslint", -- or `eslint_d`
code_actions = { -- code_actions = {
enable = true, -- enable = true,
apply_on_save = { -- apply_on_save = {
enable = true, -- enable = true,
types = { "directive", "problem", "suggestion", "layout" }, -- types = { "directive", "problem", "suggestion", "layout" },
}, -- },
disable_rule_comment = { -- disable_rule_comment = {
enable = true, -- enable = true,
location = "separate_line", -- or `same_line` -- location = "separate_line", -- or `same_line`
}, -- },
}, -- },
diagnostics = { -- diagnostics = {
enable = true, -- enable = true,
report_unused_disable_directives = false, -- report_unused_disable_directives = false,
run_on = "type", -- or `save` -- run_on = "type", -- or `save`
}, -- },
}) -- })

53
lua/vscSetup.lua Normal file
View file

@ -0,0 +1,53 @@
vim.keymap.set("n", ";", ":")
vim.opt.expandtab = true
vim.opt.tabstop = 4
vim.opt.smarttab = true
vim.opt.shiftround = true
vim.opt.shiftwidth = 4
vim.opt.smartcase = true
vim.opt.ignorecase = true
vim.opt.scrolloff = 6
-- eregex.vim
vim.g.eregex_default_enable = 1
--KEYMAP
vim.g.mapleader = " "
local vsc = require("vscode")
vim.keymap.set("n", "<C-t>", function()
vsc.action("workbench.action.toggleSidebarVisibility")
end)
vim.keymap.set("n", "<leader>`", function()
vsc.action("workbench.action.terminal.toggleTerminal")
end)
vim.keymap.set("v", "<leader>se", function ()
vsc.action("editor.emmet.action.wrapWithAbbreviation")
end)
vim.keymap.set("n", "<leader>lg", function ()
vsc.action("lazygit.openLazygit")
end)
-- for some reason, this plugin does not work with keymaps that start with <C-f>
-- they are done through vsc
--
-- vim.keymap.set("n", "<C-f>v", function()
-- vsc.action("workbench.action.showAllSymbols")
-- end)
-- vim.keymap.set("n", "<C-f>f", function ()
-- vsc.action("workbench.action.quickOpen")
-- end)
-- vim.keymap.set("n", "<C-f>t", function ()
-- vsc.action("workbench.action.quickTextSearch")
-- end)
vim.keymap.set("n", "<leader>e", function()
-- print((":e " .. string.gsub(vim.fn.expand("%"), '(.*/)(.*)', '%1')));
vim.api.nvim_feedkeys((":e " .. string.gsub(vim.fn.expand("%"), "(.*/)(.*)", "%1")), "L", false)
end)
vim.keymap.set("n", "<leader>c", ":let @+=@\"<CR>")
vim.keymap.set("n", "<C-k>z", function ()
vsc.action("workbench.action.toggleZenMode")
end)
vim.keymap.set("v", "<leader>h", ":S/", {
noremap = true,
})
vim.keymap.set("n", "<leader>h", ":%S/", {
noremap = true,
})

38
lua/vscodePlugins.lua Normal file
View file

@ -0,0 +1,38 @@
local plugins = {
{
"christoomey/vim-titlecase"
},
{
vscode = true,
"kylechui/nvim-surround",
version = "*", -- Use for stability; omit to use `main` branch for the latest features
event = "VeryLazy",
config = function()
require("nvim-surround").setup({
keymaps = {
visual = "<leader>s",
visual_line = "<leader>s",
},
})
end,
},
{
vscode = true,
"lambdalisue/suda.vim",
},
{
"sadan4/eregex.vim",
},
{
vscode = true,
"iamcco/markdown-preview.nvim",
cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" },
ft = { "markdown" },
build = function()
vim.fn["mkdp#util#install"]()
end,
},
}
require("lazy").setup(plugins, {})
require("vscSetup")