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
vim.opt.rtp:prepend(lazypath)
if vim.g.vscode then
require"vscodePlugins"
else
require"plugins"
require"setup"
require"keymap"
require"sets"
end

View file

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

View file

@ -1,4 +1,7 @@
local plugins = {
{
"christoomey/vim-titlecase"
},
{
"kylechui/nvim-surround",
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",
},
{
"MunifTanjim/eslint.nvim",
},
-- {
-- "MunifTanjim/eslint.nvim",
-- },
{
"williamboman/mason.nvim",
},

View file

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

View file

@ -9,7 +9,42 @@ capabilities.textDocument.foldingRange = {
dynamicRegistration = false,
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
local function setupJDTLS()
local mason_registry = require("mason-registry")
@ -109,7 +144,7 @@ end
-- })
-- ENDjdtls
require("lspconfig").emmet_language_server.setup({
filetypes = {"css", "scss", "sass", "less", "html"}
filetypes = {"css", "scss", "sass", "less", "html"},
capabilities = capabilities,
})
require("lspconfig").cssls.setup({
@ -243,22 +278,22 @@ require("setupclangdext")
require("null-ls").setup()
require("eslint").setup({
bin = "eslint_d", -- or `eslint`
code_actions = {
enable = true,
apply_on_save = {
enable = true,
types = { "directive", "problem", "suggestion", "layout" },
},
disable_rule_comment = {
enable = true,
location = "separate_line", -- or `same_line`
},
},
diagnostics = {
enable = true,
report_unused_disable_directives = false,
run_on = "type", -- or `save`
},
})
-- require("eslint").setup({
-- bin = "eslint", -- or `eslint_d`
-- code_actions = {
-- enable = true,
-- apply_on_save = {
-- enable = true,
-- types = { "directive", "problem", "suggestion", "layout" },
-- },
-- disable_rule_comment = {
-- enable = true,
-- location = "separate_line", -- or `same_line`
-- },
-- },
-- diagnostics = {
-- enable = true,
-- report_unused_disable_directives = false,
-- 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")