diff --git a/nvim/m-housh/lua/user/plugin/formatter.lua b/nvim/m-housh/lua/user/plugin/formatter.lua index b7d55b3..d17921e 100755 --- a/nvim/m-housh/lua/user/plugin/formatter.lua +++ b/nvim/m-housh/lua/user/plugin/formatter.lua @@ -22,11 +22,34 @@ return { try_node_modules = true, } end, + swift = function() + return { + exe = "swiftformat", + } + end, ["*"] = { -- formatter for any / all file types. require("formatter.filetypes.any").remove_trailing_whitespace } } }) + + -- Keymaps + local wk = require('which-key') + wk.add({ + { "f", ":Format", desc = "[F]ormat" }, + { "F", ":FormateWrite", desc = "[F]ormat write" } + }, + { mode = 'n', silent = true } + ) + + local augroup = vim.api.nvim_create_augroup + local autocmd = vim.api.nvim_create_autocmd + + augroup("__formatter__", { clear = true }) + autocmd("BufWritePost", { + group = "__formatter__", + command = ":FormatWrite" + }) end } diff --git a/nvim/m-housh/lua/user/plugin/lsp.lua b/nvim/m-housh/lua/user/plugin/lsp.lua index 156eac7..0f04723 100755 --- a/nvim/m-housh/lua/user/plugin/lsp.lua +++ b/nvim/m-housh/lua/user/plugin/lsp.lua @@ -34,190 +34,286 @@ return { } } }, + { "neovim/nvim-lspconfig", - dependencies = { - "hrsh7th/cmp-nvim-lsp", - }, + event = { "BufReadPost", "BufNewFile" }, + cmd = { "LspInfo", "LspInstall", "LspUninstall", "LspStart", "LspStop", "LspRestart" }, config = function() require('neodev').setup() require("mason").setup() require("mason-lspconfig").setup() - local nvim_lsp = require("lspconfig") - local telescope_builtin = require('telescope.builtin') + local lspconfig = require('lspconfig') - vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('my-lsp-attach', { clear = true }), - callback = function(event) - -- Helper function to create a keymap. - local map = function(keys, func, desc) - vim.keymap.set('n', keys, func, { buffer = true, desc = 'LSP: ' .. desc }) - end - - -- Mappings. - -- See `:help vim.lsp.*` for documentation on any of the below functions - - map('[d', 'lua vim.lsp.diagnostic.goto_prev()', 'Goto previous') - map(']d', 'lua vim.lsp.diagnostic.goto_next()', 'Goto next') - map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') - map('D', vim.lsp.buf.type_definition, 'Type [D]efinition') - map('f', vim.lsp.buf.format, '[F]ormat') - map('rn', vim.lsp.buf.rename, '[R]e[n]ame') - map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - map('gd', telescope_builtin.lsp_definitions, '[G]oto [D]efinition') - map('gi', telescope_builtin.lsp_implementations, '[G]oto, [I]mplementation') - map('gr', telescope_builtin.lsp_references, '[G]oto [R]eferences') - map('gt', telescope_builtin.lsp_type_definitions, '[T]ype Definitions') - map('K', vim.lsp.buf.hover, 'Hover Documentation') - --- -- buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) --- buf_set_keymap("n", "wa", --- "lua vim.lsp.buf.add_workspace_folder()", opts) --- buf_set_keymap("n", "wr", --- "lua vim.lsp.buf.remove_workspace_folder()", opts) --- buf_set_keymap("n", "wl", --- "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))", --- opts) --- buf_set_keymap("n", "e", "lua vim.lsp.diagnostic.show_line_diagnostics()", opts) --- buf_set_keymap("n", "q", "lua vim.lsp.diagnostic.set_loclist()", opts) - vim.api.nvim_buf_set_option(event.buf, 'omnifunc', 'v:lua.vim.lsp.omnifunc') - end, + lspconfig.bashls.setup {} + lspconfig.clangd.setup {} + lspconfig.dockerls.setup {} + lspconfig.gopls.setup {} + lspconfig.jsonls.setup {} + lspconfig.lua_ls.setup {} + lspconfig.marksman.setup {} + lspconfig.yamlls.setup {} + lspconfig.sourcekit.setup({ + capabilities = { + workspace = { + didChangeWatchedFiles = { + dynamicRegistration = true, + }, + }, + }, }) - -- Use a loop to conveniently call 'setup' on multiple servers and - -- map buffer local keybindings when the language server attaches - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) + vim.api.nvim_create_autocmd('LspAttach', { + desc = 'LSP Actions', + callback = function(args) + -- Configure keybindings once we've attached. + local wk = require('which-key') - local servers = { - "bashls", - "clangd", - "dockerls", - "gopls", - "jsonls", - "jedi_language_server", - "lua_ls", - "marksman", - "sourcekit", - "terraformls", - "ts_ls", - "texlab", - "yamlls", - } - - for _, lsp in ipairs(servers) do - nvim_lsp[lsp].setup { - capabilities = capabilities, - settings = { - gopls = { - experimentalPostfixCompletions = true, - analyses = { - unusedparams = true, - shadow = true - }, - staticcheck = true - }, - lua_ls = { - Lua = { - completion = { - callSnippet = "Replace" - }, - workspace = { checkThirdParty = false }, - telemetry = { enable = false }, - } - }, - json = { - format = {enabled = false}, - schemas = { - { - description = "ESLint config", - fileMatch = {".eslintrc.json", ".eslintrc"}, - url = "http://json.schemastore.org/eslintrc" - }, { - description = "Package config", - fileMatch = {"package.json"}, - url = "https://json.schemastore.org/package" - }, { - description = "Packer config", - fileMatch = {"packer.json"}, - url = "https://json.schemastore.org/packer" - }, { - description = "Renovate config", - fileMatch = { - "renovate.json", "renovate.json5", - ".github/renovate.json", ".github/renovate.json5", - ".renovaterc", ".renovaterc.json" - }, - url = "https://docs.renovatebot.com/renovate-schema" - }, { - description = "OpenApi config", - fileMatch = {"*api*.json"}, - url = "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.1/schema.json" - } - } - }, - redhat = {telemetry = {enabled = false}}, - texlab = { - auxDirectory = ".", - bibtexFormatter = "texlab", - build = { - args = { - "--keep-intermediates", "--keep-logs", "--synctex", "%f" - }, - executable = "tectonic", - forwardSearchAfter = false, - onSave = false - }, - chktex = {onEdit = false, onOpenAndSave = false}, - diagnosticsDelay = 300, - formatterLineLength = 80, - forwardSearch = {args = {}}, - latexFormatter = "latexindent", - latexindent = {modifyLineBreaks = false} - }, - yaml = { - schemaStore = { - enable = true, - url = "https://www.schemastore.org/api/json/catalog.json" - }, - schemas = { - kubernetes = "/*.yaml", - ["http://json.schemastore.org/github-workflow"] = ".github/workflows/*.{yml,yaml}", - ["http://json.schemastore.org/github-action"] = ".github/action.{yml,yaml}", - ["http://json.schemastore.org/ansible-stable-2.9"] = "roles/tasks/*.{yml,yaml}", - ["http://json.schemastore.org/prettierrc"] = ".prettierrc.{yml,yaml}", - ["http://json.schemastore.org/kustomization"] = "kustomization.{yml,yaml}", - ["http://json.schemastore.org/ansible-playbook"] = "*play*.{yml,yaml}", - ["http://json.schemastore.org/chart"] = "Chart.{yml,yaml}", - ["https://json.schemastore.org/dependabot-v2"] = ".github/dependabot.{yml,yaml}", - ["https://json.schemastore.org/gitlab-ci"] = "*gitlab-ci*.{yml,yaml}", - ["https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.1/schema.json"] = "*api*.{yml,yaml}", - ["https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json"] = "docker-compose.{yml,yaml}", - ["https://raw.githubusercontent.com/argoproj/argo-workflows/master/api/jsonschema/schema.json"] = "*flow*.{yml,yaml}" - }, - format = {enabled = false}, - validate = false, -- TODO: conflicts between Kubernetes resources and kustomization.yaml - completion = true, - hover = true - } - }, - flags = {debounce_text_changes = 150} - } - require"lsp_signature".setup({ - bind = true, -- This is mandatory, otherwise border config won't get registered. - floating_window = true, -- show hint in a floating window, set to false for virtual text only mode - doc_lines = 2, -- Set to 0 for not showing doc - hint_prefix = "🐼 ", - -- use_lspsaga = false, -- set to true if you want to use lspsaga popup - handler_opts = { - border = "shadow" -- double, single, shadow, none - } + wk.add({ + { "K", vim.lsp.buf.hover, desc = "LSP hover info" }, + { "gd", vim.lsp.buf.definition, desc = "[G]oto [D]efinition" }, + { "gD", vim.lsp.buf.declaration, desc = "[G]oto [D]eclaration" }, + { "gi", vim.lsp.buf.implementation, desc = "[G]oto [I]mplementation" }, + { "gr", vim.lsp.buf.references, desc = "List [R]eferences" }, + {"gs", vim.lsp.buf.signature_help, desc = "[S]ignature help" }, + { "rn", vim.lsp.buf.rename, desc = "[R]e[N]ame" }, + { "[d", vim.diagnostic.goto_prev, desc = "Go to previous diagnostic" }, + { "]d", vim.diagnostic.goto_prev, desc = "Go to next diagnostic" }, + }, { + mode = 'n', + silent = true }) - end - - -- Test source-kit - require('lspconfig').sourcekit.setup{} - + end, + }) end } } +-- return { +-- { +-- "williamboman/nvim-lsp-installer", +-- config = function() +-- require("nvim-lsp-installer").setup({}) +-- end +-- }, +-- { +-- "williamboman/mason-lspconfig.nvim", +-- dependencies = { +-- "williamboman/mason.nvim", +-- "onsails/lspkind-nvim", +-- "famiu/bufdelete.nvim", +-- "ray-x/lsp_signature.nvim", +-- "neovim/nvim-lspconfig", +-- "folke/neodev.nvim", +-- "mhartington/formatter.nvim", +-- "ray-x/go.nvim", +-- }, +-- opts = { +-- ensure_installed = { +-- "bashls", +-- "clangd", +-- "dockerls", +-- "gopls", +-- "jsonls", +-- "jedi_language_server", +-- "lua_ls", +-- "marksman", +-- "terraformls", +-- "ts_ls", +-- "texlab", +-- "yamlls", +-- } +-- } +-- }, +-- { +-- "neovim/nvim-lspconfig", +-- dependencies = { +-- "hrsh7th/cmp-nvim-lsp", +-- }, +-- config = function() +-- require('neodev').setup() +-- require("mason").setup() +-- require("mason-lspconfig").setup() +-- local nvim_lsp = require("lspconfig") +-- local telescope_builtin = require('telescope.builtin') +-- +-- vim.api.nvim_create_autocmd('LspAttach', { +-- group = vim.api.nvim_create_augroup('my-lsp-attach', { clear = true }), +-- callback = function(event) +-- -- Helper function to create a keymap. +-- local map = function(keys, func, desc) +-- vim.keymap.set('n', keys, func, { buffer = true, desc = 'LSP: ' .. desc }) +-- end +-- +-- -- Mappings. +-- -- See `:help vim.lsp.*` for documentation on any of the below functions +-- +-- map('[d', 'lua vim.lsp.diagnostic.goto_prev()', 'Goto previous') +-- map(']d', 'lua vim.lsp.diagnostic.goto_next()', 'Goto next') +-- map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') +-- map('rn', vim.lsp.buf.rename, '[R]e[n]ame') +-- map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') +-- map('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') +-- map('gi', telescope_builtin.lsp_implementations, '[G]oto, [I]mplementation') +-- map('gr', telescope_builtin.lsp_references, '[G]oto [R]eferences') +-- map('gt', telescope_builtin.lsp_type_definitions, '[T]ype Definitions') +-- map('K', vim.lsp.buf.hover, 'Hover Documentation') +-- +-- -- -- buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) +-- -- buf_set_keymap("n", "wa", +-- -- "lua vim.lsp.buf.add_workspace_folder()", opts) +-- -- buf_set_keymap("n", "wr", +-- -- "lua vim.lsp.buf.remove_workspace_folder()", opts) +-- -- buf_set_keymap("n", "wl", +-- -- "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))", +-- -- opts) +-- -- buf_set_keymap("n", "e", "lua vim.lsp.diagnostic.show_line_diagnostics()", opts) +-- -- buf_set_keymap("n", "q", "lua vim.lsp.diagnostic.set_loclist()", opts) +-- vim.api.nvim_buf_set_option(event.buf, 'omnifunc', 'v:lua.vim.lsp.omnifunc') +-- end, +-- }) +-- +-- -- Use a loop to conveniently call 'setup' on multiple servers and +-- -- map buffer local keybindings when the language server attaches +-- local capabilities = vim.lsp.protocol.make_client_capabilities() +-- capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) +-- +-- local servers = { +-- "bashls", +-- "clangd", +-- "dockerls", +-- "gopls", +-- "jsonls", +-- "jedi_language_server", +-- "lua_ls", +-- "marksman", +-- "sourcekit", +-- "terraformls", +-- "ts_ls", +-- "texlab", +-- "yamlls", +-- } +-- +-- for _, lsp in ipairs(servers) do +-- nvim_lsp[lsp].setup { +-- capabilities = capabilities, +-- settings = { +-- gopls = { +-- experimentalPostfixCompletions = true, +-- analyses = { +-- unusedparams = true, +-- shadow = true +-- }, +-- staticcheck = true +-- }, +-- lua_ls = { +-- Lua = { +-- completion = { +-- callSnippet = "Replace" +-- }, +-- workspace = { checkThirdParty = false }, +-- telemetry = { enable = false }, +-- } +-- }, +-- json = { +-- format = {enabled = false}, +-- schemas = { +-- { +-- description = "ESLint config", +-- fileMatch = {".eslintrc.json", ".eslintrc"}, +-- url = "http://json.schemastore.org/eslintrc" +-- }, { +-- description = "Package config", +-- fileMatch = {"package.json"}, +-- url = "https://json.schemastore.org/package" +-- }, { +-- description = "Packer config", +-- fileMatch = {"packer.json"}, +-- url = "https://json.schemastore.org/packer" +-- }, { +-- description = "Renovate config", +-- fileMatch = { +-- "renovate.json", "renovate.json5", +-- ".github/renovate.json", ".github/renovate.json5", +-- ".renovaterc", ".renovaterc.json" +-- }, +-- url = "https://docs.renovatebot.com/renovate-schema" +-- }, { +-- description = "OpenApi config", +-- fileMatch = {"*api*.json"}, +-- url = "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.1/schema.json" +-- } +-- } +-- }, +-- redhat = {telemetry = {enabled = false}}, +-- texlab = { +-- auxDirectory = ".", +-- bibtexFormatter = "texlab", +-- build = { +-- args = { +-- "--keep-intermediates", "--keep-logs", "--synctex", "%f" +-- }, +-- executable = "tectonic", +-- forwardSearchAfter = false, +-- onSave = false +-- }, +-- chktex = {onEdit = false, onOpenAndSave = false}, +-- diagnosticsDelay = 300, +-- formatterLineLength = 80, +-- forwardSearch = {args = {}}, +-- latexFormatter = "latexindent", +-- latexindent = {modifyLineBreaks = false} +-- }, +-- yaml = { +-- schemaStore = { +-- enable = true, +-- url = "https://www.schemastore.org/api/json/catalog.json" +-- }, +-- schemas = { +-- kubernetes = "/*.yaml", +-- ["http://json.schemastore.org/github-workflow"] = ".github/workflows/*.{yml,yaml}", +-- ["http://json.schemastore.org/github-action"] = ".github/action.{yml,yaml}", +-- ["http://json.schemastore.org/ansible-stable-2.9"] = "roles/tasks/*.{yml,yaml}", +-- ["http://json.schemastore.org/prettierrc"] = ".prettierrc.{yml,yaml}", +-- ["http://json.schemastore.org/kustomization"] = "kustomization.{yml,yaml}", +-- ["http://json.schemastore.org/ansible-playbook"] = "*play*.{yml,yaml}", +-- ["http://json.schemastore.org/chart"] = "Chart.{yml,yaml}", +-- ["https://json.schemastore.org/dependabot-v2"] = ".github/dependabot.{yml,yaml}", +-- ["https://json.schemastore.org/gitlab-ci"] = "*gitlab-ci*.{yml,yaml}", +-- ["https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.1/schema.json"] = "*api*.{yml,yaml}", +-- ["https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json"] = "docker-compose.{yml,yaml}", +-- ["https://raw.githubusercontent.com/argoproj/argo-workflows/master/api/jsonschema/schema.json"] = "*flow*.{yml,yaml}" +-- }, +-- format = {enabled = false}, +-- validate = false, -- TODO: conflicts between Kubernetes resources and kustomization.yaml +-- completion = true, +-- hover = true +-- } +-- }, +-- flags = {debounce_text_changes = 150} +-- } +-- require"lsp_signature".setup({ +-- bind = true, -- This is mandatory, otherwise border config won't get registered. +-- floating_window = true, -- show hint in a floating window, set to false for virtual text only mode +-- doc_lines = 2, -- Set to 0 for not showing doc +-- hint_prefix = "🐼 ", +-- -- use_lspsaga = false, -- set to true if you want to use lspsaga popup +-- handler_opts = { +-- border = "shadow" -- double, single, shadow, none +-- } +-- }) +-- end +-- +-- -- Test source-kit +-- require('lspconfig').sourcekit.setup{ +-- capabilities = { +-- workspace = { +-- didChangeWatchedFiles = { +-- dynamicRegistration = true +-- } +-- } +-- } +-- } +-- +-- end +-- } +-- } diff --git a/nvim/m-housh/lua/user/plugin/nvim-lint.lua b/nvim/m-housh/lua/user/plugin/nvim-lint.lua new file mode 100644 index 0000000..d5b60e0 --- /dev/null +++ b/nvim/m-housh/lua/user/plugin/nvim-lint.lua @@ -0,0 +1,24 @@ +return { + "mfussenegger/nvim-lint", + event = { "BufReadPre", "BufNewFile" }, + config = function() + local lint = require("lint") + + lint.linters_by_ft = { + swift = { "swiftlint" }, + } + + local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) + + vim.api.nvim_create_autocmd({ "BufWritePost", "BufReadPost", "InsertLeave", "TextChanged" }, { + group = lint_augroup, + callback = function() + require("lint").try_lint() + end, + }) + + vim.keymap.set("n", "ml", function() + require("lint").try_lint() + end, { desc = "Lint file" }) + end, +} diff --git a/nvim/m-housh/lua/user/plugins.lua b/nvim/m-housh/lua/user/plugins.lua index b8f79d2..82d89c9 100755 --- a/nvim/m-housh/lua/user/plugins.lua +++ b/nvim/m-housh/lua/user/plugins.lua @@ -34,6 +34,7 @@ require("lazy").setup({ { import = 'user.plugin.treesitter' }, { import = 'user.plugin.formatter' }, { import = 'user.plugin.go' }, + { import = 'user.plugin.nvim-lint' }, --{'fladson/vim-kitty', lazy=true, }, -- Navigation -- diff --git a/zsh/config/.zshenv b/zsh/config/.zshenv index 04ba0eb..defb517 100755 --- a/zsh/config/.zshenv +++ b/zsh/config/.zshenv @@ -28,16 +28,16 @@ export GIT_DISCOVERY_ACROSS_FILESYSTEM=1 # Directories export ARCHIVE="/Volumes/Archive" export BUCKET="/Volumes/Bucket" -export REPOS="/Volumes/michael/Repos" -export GHREPOS="$REPOS/github.com/$GITUSER" -export HHEREPOS="$REPOS/github.com/hhe-dev" -export HVACIOTREPOS="$REPOS/github.com/hvac-iot" +export REPOS="/Volumes/Bucket/Repos" +export GHREPOS="$REPOS/github.com" +#export HHEREPOS="$REPOS/github.com/hhe-dev" +#export HVACIOTREPOS="$REPOS/github.com/hvac-iot" export LOCAL_REPOS="$REPOS/local" export LOCAL_ENV="$XDG_DATA_HOME/zsh/env.zsh" -export HCP_NOTES="$HHEREPOS/hcp-notes" -export HXZET="$BUCKET/Repos/github.com/hvac-hx/hx-zets" -export HAAS="$BUCKET/Repos/github.com/haas" -export HAASZET="$HAAS/zets" +#export HCP_NOTES="$HHEREPOS/hcp-notes" +#export HXZET="$BUCKET/Repos/github.com/hvac-hx/hx-zets" +#export HAAS="$BUCKET/Repos/github.com/haas" +#export HAASZET="$HAAS/zets" export DOCUMENTS="$HOME/Documents" export DOWNLOADS="$HOME/Downloads" export PDFS="$HOME/Library/Mobile Documents/com~apple~Preview/Documents"