diff --git a/init.lua b/init.lua index 53c82a8..deaed52 100644 --- a/init.lua +++ b/init.lua @@ -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 diff --git a/lua/masonDownload.lua b/lua/masonDownload.lua index d6a1951..620991d 100644 --- a/lua/masonDownload.lua +++ b/lua/masonDownload.lua @@ -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 diff --git a/lua/plugins.lua b/lua/plugins.lua index 10b062a..32e8d74 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -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", }, diff --git a/lua/setupformat.lua b/lua/setupformat.lua index eacf1cd..1f815e3 100644 --- a/lua/setupformat.lua +++ b/lua/setupformat.lua @@ -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, + require("formatter.filetypes.typescriptreact").prettier, }, - 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 - }, + -- 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() diff --git a/lua/setuplsp.lua b/lua/setuplsp.lua index 32907d3..0bf75e3 100644 --- a/lua/setuplsp.lua +++ b/lua/setuplsp.lua @@ -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"}, "", "EslintFixAll", { + 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` +-- }, +-- }) diff --git a/lua/vscSetup.lua b/lua/vscSetup.lua new file mode 100644 index 0000000..4d230fa --- /dev/null +++ b/lua/vscSetup.lua @@ -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", "", function() + vsc.action("workbench.action.toggleSidebarVisibility") +end) + +vim.keymap.set("n", "`", function() + vsc.action("workbench.action.terminal.toggleTerminal") +end) +vim.keymap.set("v", "se", function () + vsc.action("editor.emmet.action.wrapWithAbbreviation") +end) +vim.keymap.set("n", "lg", function () + vsc.action("lazygit.openLazygit") +end) +-- for some reason, this plugin does not work with keymaps that start with +-- they are done through vsc +-- +-- vim.keymap.set("n", "v", function() +-- vsc.action("workbench.action.showAllSymbols") +-- end) +-- vim.keymap.set("n", "f", function () +-- vsc.action("workbench.action.quickOpen") +-- end) +-- vim.keymap.set("n", "t", function () +-- vsc.action("workbench.action.quickTextSearch") +-- end) +vim.keymap.set("n", "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", "c", ":let @+=@\"") +vim.keymap.set("n", "z", function () + vsc.action("workbench.action.toggleZenMode") +end) +vim.keymap.set("v", "h", ":S/", { + noremap = true, +}) +vim.keymap.set("n", "h", ":%S/", { + noremap = true, +}) diff --git a/lua/vscodePlugins.lua b/lua/vscodePlugins.lua new file mode 100644 index 0000000..9866564 --- /dev/null +++ b/lua/vscodePlugins.lua @@ -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 = "s", + visual_line = "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")