From cf673381c55d8cee7fd6bda20ee99edfa00bd632 Mon Sep 17 00:00:00 2001 From: Daniel B Sherry Date: Sun, 25 May 2025 16:00:30 -0500 Subject: [PATCH] autoformat on save configured --- Saved/lsp/handlers.lua | 91 -------------- Saved/lsp/init.lua | 9 -- Saved/lsp/mason.lua | 52 -------- Saved/lsp/null-ls.lua | 19 --- Saved/lsp/settings/jsonls.lua | 197 ------------------------------ Saved/lsp/settings/lua_ls.lua | 16 --- Saved/lsp/settings/pyright.lua | 9 -- init.lua | 6 +- kickstart/health.lua | 52 -------- kickstart/plugins/debug.lua | 148 ---------------------- kickstart/plugins/gitsigns.lua | 61 --------- kickstart/plugins/indent_line.lua | 9 -- kickstart/plugins/lint.lua | 60 --------- kickstart/plugins/neo-tree.lua | 25 ---- lua/plugins.lua | 43 ++++--- lua/plugins/cmp-settings.lua | 75 ++++++++++++ lua/plugins/formatter.lua | 43 +++++++ lua/plugins/lsp-settings.lua | 69 +++++++++++ lua/plugins/lsp.lua | 130 -------------------- lua/plugins/nvim-cmp.lua | 61 --------- tester.py | 12 +- 21 files changed, 220 insertions(+), 967 deletions(-) delete mode 100644 Saved/lsp/handlers.lua delete mode 100644 Saved/lsp/init.lua delete mode 100644 Saved/lsp/mason.lua delete mode 100644 Saved/lsp/null-ls.lua delete mode 100644 Saved/lsp/settings/jsonls.lua delete mode 100644 Saved/lsp/settings/lua_ls.lua delete mode 100644 Saved/lsp/settings/pyright.lua delete mode 100644 kickstart/health.lua delete mode 100644 kickstart/plugins/debug.lua delete mode 100644 kickstart/plugins/gitsigns.lua delete mode 100644 kickstart/plugins/indent_line.lua delete mode 100644 kickstart/plugins/lint.lua delete mode 100644 kickstart/plugins/neo-tree.lua create mode 100644 lua/plugins/cmp-settings.lua create mode 100644 lua/plugins/formatter.lua create mode 100644 lua/plugins/lsp-settings.lua delete mode 100644 lua/plugins/lsp.lua delete mode 100644 lua/plugins/nvim-cmp.lua diff --git a/Saved/lsp/handlers.lua b/Saved/lsp/handlers.lua deleted file mode 100644 index b540d09b..00000000 --- a/Saved/lsp/handlers.lua +++ /dev/null @@ -1,91 +0,0 @@ -local M = {} - -local status_cmp_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") -if not status_cmp_ok then - return -end - -M.capabilities = vim.lsp.protocol.make_client_capabilities() -M.capabilities.textDocument.completion.completionItem.snippetSupport = true -M.capabilities = cmp_nvim_lsp.default_capabilities(M.capabilities) - -M.setup = function() - local signs = { - - { name = "DiagnosticSignError", text = "" }, - { name = "DiagnosticSignWarn", text = "" }, - { name = "DiagnosticSignHint", text = "" }, - { name = "DiagnosticSignInfo", text = "" }, - } - - for _, sign in ipairs(signs) do - vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" }) - end - - local config = { - virtual_text = false, -- disable virtual text - signs = { - active = signs, -- show signs - }, - update_in_insert = true, - underline = true, - severity_sort = true, - float = { - focusable = true, - style = "minimal", - border = "rounded", - source = "always", - header = "", - prefix = "", - }, - } - - vim.diagnostic.config(config) - - vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { - border = "rounded", - }) - - vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { - border = "rounded", - }) -end - -local function lsp_keymaps(bufnr) - local opts = { noremap = true, silent = true } - local keymap = vim.api.nvim_buf_set_keymap - keymap(bufnr, "n", "gD", "lua vim.lsp.buf.declaration()", opts) - keymap(bufnr, "n", "gd", "lua vim.lsp.buf.definition()", opts) - keymap(bufnr, "n", "K", "lua vim.lsp.buf.hover()", opts) - keymap(bufnr, "n", "gI", "lua vim.lsp.buf.implementation()", opts) - keymap(bufnr, "n", "gr", "lua vim.lsp.buf.references()", opts) - keymap(bufnr, "n", "gl", "lua vim.diagnostic.open_float()", opts) - keymap(bufnr, "n", "lf", "lua vim.lsp.buf.format{ async = true }", opts) - keymap(bufnr, "n", "li", "LspInfo", opts) - keymap(bufnr, "n", "lI", "LspInstallInfo", opts) - keymap(bufnr, "n", "la", "lua vim.lsp.buf.code_action()", opts) - keymap(bufnr, "n", "lj", "lua vim.diagnostic.goto_next({buffer=0})", opts) - keymap(bufnr, "n", "lk", "lua vim.diagnostic.goto_prev({buffer=0})", opts) - keymap(bufnr, "n", "lr", "lua vim.lsp.buf.rename()", opts) - keymap(bufnr, "n", "ls", "lua vim.lsp.buf.signature_help()", opts) - keymap(bufnr, "n", "lq", "lua vim.diagnostic.setloclist()", opts) -end - -M.on_attach = function(client, bufnr) - if client.name == "tsserver" then - client.server_capabilities.documentFormattingProvider = false - end - - if client.name == "sumneko_lua" then - client.server_capabilities.documentFormattingProvider = false - end - - lsp_keymaps(bufnr) - local status_ok, illuminate = pcall(require, "illuminate") - if not status_ok then - return - end - illuminate.on_attach(client) -end - -return M diff --git a/Saved/lsp/init.lua b/Saved/lsp/init.lua deleted file mode 100644 index 0cc7120d..00000000 --- a/Saved/lsp/init.lua +++ /dev/null @@ -1,9 +0,0 @@ -local status_ok, _ = pcall(require, "lspconfig") -if not status_ok then - return -end - -require "user.lsp.mason" -require("user.lsp.handlers").setup() -require "user.lsp.null-ls" - diff --git a/Saved/lsp/mason.lua b/Saved/lsp/mason.lua deleted file mode 100644 index 48e02aed..00000000 --- a/Saved/lsp/mason.lua +++ /dev/null @@ -1,52 +0,0 @@ -local servers = { - "lua_ls", - -- "cssls", - -- "html", - -- "tsserver", - "pyright", - -- "bashls", - "jsonls", - -- "yamlls", -} - -local settings = { - ui = { - border = "none", - icons = { - package_installed = "◍", - package_pending = "◍", - package_uninstalled = "◍", - }, - }, - log_level = vim.log.levels.INFO, - max_concurrent_installers = 4, -} - -require("mason").setup(settings) --- require("mason-lspconfig").setup({ --- ensure_installed = servers, --- automatic_installation = true, --- }) - -local lspconfig_status_ok, lspconfig = pcall(require, "lspconfig") -if not lspconfig_status_ok then - return -end - -local opts = {} - -for _, server in pairs(servers) do - opts = { - on_attach = require("user.lsp.handlers").on_attach, - capabilities = require("user.lsp.handlers").capabilities, - } - - server = vim.split(server, "@")[1] - - local require_ok, conf_opts = pcall(require, "user.lsp.settings." .. server) - if require_ok then - opts = vim.tbl_deep_extend("force", conf_opts, opts) - end - - lspconfig[server].setup(opts) -end diff --git a/Saved/lsp/null-ls.lua b/Saved/lsp/null-ls.lua deleted file mode 100644 index 874e19c5..00000000 --- a/Saved/lsp/null-ls.lua +++ /dev/null @@ -1,19 +0,0 @@ -local null_ls_status_ok, null_ls = pcall(require, "null-ls") -if not null_ls_status_ok then - return -end - --- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting -local formatting = null_ls.builtins.formatting --- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics -local diagnostics = null_ls.builtins.diagnostics - -null_ls.setup({ - debug = false, - sources = { - formatting.prettier.with({ extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } }), - formatting.black.with({ extra_args = { "--fast" } }), - formatting.stylua, - -- diagnostics.flake8 - }, -}) diff --git a/Saved/lsp/settings/jsonls.lua b/Saved/lsp/settings/jsonls.lua deleted file mode 100644 index e202e1e1..00000000 --- a/Saved/lsp/settings/jsonls.lua +++ /dev/null @@ -1,197 +0,0 @@ -local default_schemas = nil -local status_ok, jsonls_settings = pcall(require, "nlspsettings.jsonls") -if status_ok then - default_schemas = jsonls_settings.get_default_schemas() -end - -local schemas = { - { - description = "TypeScript compiler configuration file", - fileMatch = { - "tsconfig.json", - "tsconfig.*.json", - }, - url = "https://json.schemastore.org/tsconfig.json", - }, - { - description = "Lerna config", - fileMatch = { "lerna.json" }, - url = "https://json.schemastore.org/lerna.json", - }, - { - description = "Babel configuration", - fileMatch = { - ".babelrc.json", - ".babelrc", - "babel.config.json", - }, - url = "https://json.schemastore.org/babelrc.json", - }, - { - description = "ESLint config", - fileMatch = { - ".eslintrc.json", - ".eslintrc", - }, - url = "https://json.schemastore.org/eslintrc.json", - }, - { - description = "Bucklescript config", - fileMatch = { "bsconfig.json" }, - url = "https://raw.githubusercontent.com/rescript-lang/rescript-compiler/8.2.0/docs/docson/build-schema.json", - }, - { - description = "Prettier config", - fileMatch = { - ".prettierrc", - ".prettierrc.json", - "prettier.config.json", - }, - url = "https://json.schemastore.org/prettierrc", - }, - { - description = "Vercel Now config", - fileMatch = { "now.json" }, - url = "https://json.schemastore.org/now", - }, - { - description = "Stylelint config", - fileMatch = { - ".stylelintrc", - ".stylelintrc.json", - "stylelint.config.json", - }, - url = "https://json.schemastore.org/stylelintrc", - }, - { - description = "A JSON schema for the ASP.NET LaunchSettings.json files", - fileMatch = { "launchsettings.json" }, - url = "https://json.schemastore.org/launchsettings.json", - }, - { - description = "Schema for CMake Presets", - fileMatch = { - "CMakePresets.json", - "CMakeUserPresets.json", - }, - url = "https://raw.githubusercontent.com/Kitware/CMake/master/Help/manual/presets/schema.json", - }, - { - description = "Configuration file as an alternative for configuring your repository in the settings page.", - fileMatch = { - ".codeclimate.json", - }, - url = "https://json.schemastore.org/codeclimate.json", - }, - { - description = "LLVM compilation database", - fileMatch = { - "compile_commands.json", - }, - url = "https://json.schemastore.org/compile-commands.json", - }, - { - description = "Config file for Command Task Runner", - fileMatch = { - "commands.json", - }, - url = "https://json.schemastore.org/commands.json", - }, - { - description = "AWS CloudFormation provides a common language for you to describe and provision all the infrastructure resources in your cloud environment.", - fileMatch = { - "*.cf.json", - "cloudformation.json", - }, - url = "https://raw.githubusercontent.com/awslabs/goformation/v5.2.9/schema/cloudformation.schema.json", - }, - { - description = "The AWS Serverless Application Model (AWS SAM, previously known as Project Flourish) extends AWS CloudFormation to provide a simplified way of defining the Amazon API Gateway APIs, AWS Lambda functions, and Amazon DynamoDB tables needed by your serverless application.", - fileMatch = { - "serverless.template", - "*.sam.json", - "sam.json", - }, - url = "https://raw.githubusercontent.com/awslabs/goformation/v5.2.9/schema/sam.schema.json", - }, - { - description = "Json schema for properties json file for a GitHub Workflow template", - fileMatch = { - ".github/workflow-templates/**.properties.json", - }, - url = "https://json.schemastore.org/github-workflow-template-properties.json", - }, - { - description = "golangci-lint configuration file", - fileMatch = { - ".golangci.toml", - ".golangci.json", - }, - url = "https://json.schemastore.org/golangci-lint.json", - }, - { - description = "JSON schema for the JSON Feed format", - fileMatch = { - "feed.json", - }, - url = "https://json.schemastore.org/feed.json", - versions = { - ["1"] = "https://json.schemastore.org/feed-1.json", - ["1.1"] = "https://json.schemastore.org/feed.json", - }, - }, - { - description = "Packer template JSON configuration", - fileMatch = { - "packer.json", - }, - url = "https://json.schemastore.org/packer.json", - }, - { - description = "NPM configuration file", - fileMatch = { - "package.json", - }, - url = "https://json.schemastore.org/package.json", - }, - { - description = "JSON schema for Visual Studio component configuration files", - fileMatch = { - "*.vsconfig", - }, - url = "https://json.schemastore.org/vsconfig.json", - }, - { - description = "Resume json", - fileMatch = { "resume.json" }, - url = "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json", - }, -} - -local function extend(tab1, tab2) - for _, value in ipairs(tab2 or {}) do - table.insert(tab1, value) - end - return tab1 -end - -local extended_schemas = extend(schemas, default_schemas) - -local opts = { - settings = { - json = { - schemas = extended_schemas, - }, - }, - setup = { - commands = { - Format = { - function() - vim.lsp.buf.range_formatting({}, { 0, 0 }, { vim.fn.line "$", 0 }) - end, - }, - }, - }, -} - -return opts diff --git a/Saved/lsp/settings/lua_ls.lua b/Saved/lsp/settings/lua_ls.lua deleted file mode 100644 index 0ac454a7..00000000 --- a/Saved/lsp/settings/lua_ls.lua +++ /dev/null @@ -1,16 +0,0 @@ -return { - settings = { - - Lua = { - diagnostics = { - globals = { "vim" }, - }, - workspace = { - library = { - [vim.fn.expand("$VIMRUNTIME/lua")] = true, - [vim.fn.stdpath("config") .. "/lua"] = true, - }, - }, - }, - }, -} diff --git a/Saved/lsp/settings/pyright.lua b/Saved/lsp/settings/pyright.lua deleted file mode 100644 index c2a518db..00000000 --- a/Saved/lsp/settings/pyright.lua +++ /dev/null @@ -1,9 +0,0 @@ -return { - settings = { - python = { - analysis = { - typeCheckingMode = "off", - }, - }, - }, -} diff --git a/init.lua b/init.lua index ef3b323c..8890a3c4 100644 --- a/init.lua +++ b/init.lua @@ -18,7 +18,7 @@ vim.opt.rtp:prepend(lazypath) require('lazy').setup { { import = 'plugins' }, - { import = 'plugins.lsp' }, + -- { import = 'plugins.lsp' }, } require 'user.options' @@ -30,5 +30,5 @@ require 'user.autocmds' -- require 'user.treesitter' -- require 'user.autopairs' -vim.lsp.enable('pyright') -vim.lsp.enable('lua_ls') +-- vim.lsp.enable('pyright') +-- vim.lsp.enable('lua_ls') diff --git a/kickstart/health.lua b/kickstart/health.lua deleted file mode 100644 index b59d0864..00000000 --- a/kickstart/health.lua +++ /dev/null @@ -1,52 +0,0 @@ ---[[ --- --- This file is not required for your own configuration, --- but helps people determine if their system is setup correctly. --- ---]] - -local check_version = function() - local verstr = tostring(vim.version()) - if not vim.version.ge then - vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr)) - return - end - - if vim.version.ge(vim.version(), '0.10-dev') then - vim.health.ok(string.format("Neovim version is: '%s'", verstr)) - else - vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr)) - end -end - -local check_external_reqs = function() - -- Basic utils: `git`, `make`, `unzip` - for _, exe in ipairs { 'git', 'make', 'unzip', 'rg' } do - local is_executable = vim.fn.executable(exe) == 1 - if is_executable then - vim.health.ok(string.format("Found executable: '%s'", exe)) - else - vim.health.warn(string.format("Could not find executable: '%s'", exe)) - end - end - - return true -end - -return { - check = function() - vim.health.start 'kickstart.nvim' - - vim.health.info [[NOTE: Not every warning is a 'must-fix' in `:checkhealth` - - Fix only warnings for plugins and languages you intend to use. - Mason will give warnings for languages that are not installed. - You do not need to install, unless you want to use those languages!]] - - local uv = vim.uv or vim.loop - vim.health.info('System Information: ' .. vim.inspect(uv.os_uname())) - - check_version() - check_external_reqs() - end, -} diff --git a/kickstart/plugins/debug.lua b/kickstart/plugins/debug.lua deleted file mode 100644 index 753cb0ce..00000000 --- a/kickstart/plugins/debug.lua +++ /dev/null @@ -1,148 +0,0 @@ --- debug.lua --- --- Shows how to use the DAP plugin to debug your code. --- --- Primarily focused on configuring the debugger for Go, but can --- be extended to other languages as well. That's why it's called --- kickstart.nvim and not kitchen-sink.nvim ;) - -return { - -- NOTE: Yes, you can install new plugins here! - 'mfussenegger/nvim-dap', - -- NOTE: And you can specify dependencies as well - dependencies = { - -- Creates a beautiful debugger UI - 'rcarriga/nvim-dap-ui', - - -- Required dependency for nvim-dap-ui - 'nvim-neotest/nvim-nio', - - -- Installs the debug adapters for you - 'williamboman/mason.nvim', - 'jay-babu/mason-nvim-dap.nvim', - - -- Add your own debuggers here - 'leoluz/nvim-dap-go', - }, - keys = { - -- Basic debugging keymaps, feel free to change to your liking! - { - '', - function() - require('dap').continue() - end, - desc = 'Debug: Start/Continue', - }, - { - '', - function() - require('dap').step_into() - end, - desc = 'Debug: Step Into', - }, - { - '', - function() - require('dap').step_over() - end, - desc = 'Debug: Step Over', - }, - { - '', - function() - require('dap').step_out() - end, - desc = 'Debug: Step Out', - }, - { - 'b', - function() - require('dap').toggle_breakpoint() - end, - desc = 'Debug: Toggle Breakpoint', - }, - { - 'B', - function() - require('dap').set_breakpoint(vim.fn.input 'Breakpoint condition: ') - end, - desc = 'Debug: Set Breakpoint', - }, - -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception. - { - '', - function() - require('dapui').toggle() - end, - desc = 'Debug: See last session result.', - }, - }, - config = function() - local dap = require 'dap' - local dapui = require 'dapui' - - require('mason-nvim-dap').setup { - -- Makes a best effort to setup the various debuggers with - -- reasonable debug configurations - automatic_installation = true, - - -- You can provide additional configuration to the handlers, - -- see mason-nvim-dap README for more information - handlers = {}, - - -- You'll need to check that you have the required things installed - -- online, please don't ask me how to install them :) - ensure_installed = { - -- Update this to ensure that you have the debuggers for the langs you want - 'delve', - }, - } - - -- Dap UI setup - -- For more information, see |:help nvim-dap-ui| - dapui.setup { - -- Set icons to characters that are more likely to work in every terminal. - -- Feel free to remove or use ones that you like more! :) - -- Don't feel like these are good choices. - icons = { expanded = '▾', collapsed = '▸', current_frame = '*' }, - controls = { - icons = { - pause = '⏸', - play = '▶', - step_into = '⏎', - step_over = '⏭', - step_out = '⏮', - step_back = 'b', - run_last = '▶▶', - terminate = '⏹', - disconnect = '⏏', - }, - }, - } - - -- Change breakpoint icons - -- vim.api.nvim_set_hl(0, 'DapBreak', { fg = '#e51400' }) - -- vim.api.nvim_set_hl(0, 'DapStop', { fg = '#ffcc00' }) - -- local breakpoint_icons = vim.g.have_nerd_font - -- and { Breakpoint = '', BreakpointCondition = '', BreakpointRejected = '', LogPoint = '', Stopped = '' } - -- or { Breakpoint = '●', BreakpointCondition = '⊜', BreakpointRejected = '⊘', LogPoint = '◆', Stopped = '⭔' } - -- for type, icon in pairs(breakpoint_icons) do - -- local tp = 'Dap' .. type - -- local hl = (type == 'Stopped') and 'DapStop' or 'DapBreak' - -- vim.fn.sign_define(tp, { text = icon, texthl = hl, numhl = hl }) - -- end - - dap.listeners.after.event_initialized['dapui_config'] = dapui.open - dap.listeners.before.event_terminated['dapui_config'] = dapui.close - dap.listeners.before.event_exited['dapui_config'] = dapui.close - - -- Install golang specific config - require('dap-go').setup { - delve = { - -- On Windows delve must be run attached or it crashes. - -- See https://github.com/leoluz/nvim-dap-go/blob/main/README.md#configuring - detached = vim.fn.has 'win32' == 0, - }, - } - end, -} diff --git a/kickstart/plugins/gitsigns.lua b/kickstart/plugins/gitsigns.lua deleted file mode 100644 index 4bcc70f4..00000000 --- a/kickstart/plugins/gitsigns.lua +++ /dev/null @@ -1,61 +0,0 @@ --- Adds git related signs to the gutter, as well as utilities for managing changes --- NOTE: gitsigns is already included in init.lua but contains only the base --- config. This will add also the recommended keymaps. - -return { - { - 'lewis6991/gitsigns.nvim', - opts = { - on_attach = function(bufnr) - local gitsigns = require 'gitsigns' - - local function map(mode, l, r, opts) - opts = opts or {} - opts.buffer = bufnr - vim.keymap.set(mode, l, r, opts) - end - - -- Navigation - map('n', ']c', function() - if vim.wo.diff then - vim.cmd.normal { ']c', bang = true } - else - gitsigns.nav_hunk 'next' - end - end, { desc = 'Jump to next git [c]hange' }) - - map('n', '[c', function() - if vim.wo.diff then - vim.cmd.normal { '[c', bang = true } - else - gitsigns.nav_hunk 'prev' - end - end, { desc = 'Jump to previous git [c]hange' }) - - -- Actions - -- visual mode - map('v', 'hs', function() - gitsigns.stage_hunk { vim.fn.line '.', vim.fn.line 'v' } - end, { desc = 'stage git hunk' }) - map('v', 'hr', function() - gitsigns.reset_hunk { vim.fn.line '.', vim.fn.line 'v' } - end, { desc = 'reset git hunk' }) - -- normal mode - map('n', 'hs', gitsigns.stage_hunk, { desc = 'git [s]tage hunk' }) - map('n', 'hr', gitsigns.reset_hunk, { desc = 'git [r]eset hunk' }) - map('n', 'hS', gitsigns.stage_buffer, { desc = 'git [S]tage buffer' }) - map('n', 'hu', gitsigns.undo_stage_hunk, { desc = 'git [u]ndo stage hunk' }) - map('n', 'hR', gitsigns.reset_buffer, { desc = 'git [R]eset buffer' }) - map('n', 'hp', gitsigns.preview_hunk, { desc = 'git [p]review hunk' }) - map('n', 'hb', gitsigns.blame_line, { desc = 'git [b]lame line' }) - map('n', 'hd', gitsigns.diffthis, { desc = 'git [d]iff against index' }) - map('n', 'hD', function() - gitsigns.diffthis '@' - end, { desc = 'git [D]iff against last commit' }) - -- Toggles - map('n', 'tb', gitsigns.toggle_current_line_blame, { desc = '[T]oggle git show [b]lame line' }) - map('n', 'tD', gitsigns.toggle_deleted, { desc = '[T]oggle git show [D]eleted' }) - end, - }, - }, -} diff --git a/kickstart/plugins/indent_line.lua b/kickstart/plugins/indent_line.lua deleted file mode 100644 index ed7f2693..00000000 --- a/kickstart/plugins/indent_line.lua +++ /dev/null @@ -1,9 +0,0 @@ -return { - { -- Add indentation guides even on blank lines - 'lukas-reineke/indent-blankline.nvim', - -- Enable `lukas-reineke/indent-blankline.nvim` - -- See `:help ibl` - main = 'ibl', - opts = {}, - }, -} diff --git a/kickstart/plugins/lint.lua b/kickstart/plugins/lint.lua deleted file mode 100644 index 907c6bf3..00000000 --- a/kickstart/plugins/lint.lua +++ /dev/null @@ -1,60 +0,0 @@ -return { - - { -- Linting - 'mfussenegger/nvim-lint', - event = { 'BufReadPre', 'BufNewFile' }, - config = function() - local lint = require 'lint' - lint.linters_by_ft = { - markdown = { 'markdownlint' }, - } - - -- To allow other plugins to add linters to require('lint').linters_by_ft, - -- instead set linters_by_ft like this: - -- lint.linters_by_ft = lint.linters_by_ft or {} - -- lint.linters_by_ft['markdown'] = { 'markdownlint' } - -- - -- However, note that this will enable a set of default linters, - -- which will cause errors unless these tools are available: - -- { - -- clojure = { "clj-kondo" }, - -- dockerfile = { "hadolint" }, - -- inko = { "inko" }, - -- janet = { "janet" }, - -- json = { "jsonlint" }, - -- markdown = { "vale" }, - -- rst = { "vale" }, - -- ruby = { "ruby" }, - -- terraform = { "tflint" }, - -- text = { "vale" } - -- } - -- - -- You can disable the default linters by setting their filetypes to nil: - -- lint.linters_by_ft['clojure'] = nil - -- lint.linters_by_ft['dockerfile'] = nil - -- lint.linters_by_ft['inko'] = nil - -- lint.linters_by_ft['janet'] = nil - -- lint.linters_by_ft['json'] = nil - -- lint.linters_by_ft['markdown'] = nil - -- lint.linters_by_ft['rst'] = nil - -- lint.linters_by_ft['ruby'] = nil - -- lint.linters_by_ft['terraform'] = nil - -- lint.linters_by_ft['text'] = nil - - -- Create autocommand which carries out the actual linting - -- on the specified events. - local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true }) - vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, { - group = lint_augroup, - callback = function() - -- Only run the linter in buffers that you can modify in order to - -- avoid superfluous noise, notably within the handy LSP pop-ups that - -- describe the hovered symbol using Markdown. - if vim.opt_local.modifiable:get() then - lint.try_lint() - end - end, - }) - end, - }, -} diff --git a/kickstart/plugins/neo-tree.lua b/kickstart/plugins/neo-tree.lua deleted file mode 100644 index bd442269..00000000 --- a/kickstart/plugins/neo-tree.lua +++ /dev/null @@ -1,25 +0,0 @@ --- Neo-tree is a Neovim plugin to browse the file system --- https://github.com/nvim-neo-tree/neo-tree.nvim - -return { - 'nvim-neo-tree/neo-tree.nvim', - version = '*', - dependencies = { - 'nvim-lua/plenary.nvim', - 'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended - 'MunifTanjim/nui.nvim', - }, - cmd = 'Neotree', - keys = { - { '\\', ':Neotree reveal', desc = 'NeoTree reveal', silent = true }, - }, - opts = { - filesystem = { - window = { - mappings = { - ['\\'] = 'close_window', - }, - }, - }, - }, -} diff --git a/lua/plugins.lua b/lua/plugins.lua index 9a9ff67f..4d6d862a 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -1,6 +1,6 @@ return { - {'folke/tokyonight.nvim'}, - { "nvim-lua/popup.nvim" }, -- An implementation of the Popup API from vim in Neovim + { 'folke/tokyonight.nvim' }, + { "nvim-lua/popup.nvim" }, -- An implementation of the Popup API from vim in Neovim { "nvim-lua/plenary.nvim" }, -- Useful lua functions used ny lots of plugins { "windwp/nvim-autopairs" }, -- Autopairs -- "numToStr/Comment.nvim" -- Easily comment stuff @@ -9,25 +9,12 @@ return { -- "lunarvim/colorschemes" -- A bunch of colorschemes you can try out { "lunarvim/darkplus.nvim" }, { "moll/vim-bbye" }, --- cmp plugins - -- { "hrsh7th/nvim-cmp" }, -- The completion plugin - -- { "hrsh7th/cmp-buffer" }, -- buffer completions - -- { "hrsh7th/cmp-path" }, -- path completions - -- { "hrsh7th/cmp-nvim-lua" }, - -- { "hrsh7th/cmp-cmdline" }, -- cmdline completions - -- { "saadparwaiz1/cmp_luasnip" }, -- snippet completions - -- { "hrsh7th/cmp-nvim-lsp" }, --- snippets - { "L3MON4D3/LuaSnip" }, --snippet engine + -- snippets + { "L3MON4D3/LuaSnip" }, --snippet engine { "rafamadriz/friendly-snippets" }, -- a bunch of snippets to use --- LSP - -- { "neovim/nvim-lspconfig" }, -- enable LSP - -- { "williamboman/mason.nvim" }, -- simple to use language server installer - -- { "williamboman/mason-lspconfig.nvim" }, -- simple to use language server installer - --- Telescope + -- Telescope { "nvim-telescope/telescope-media-files.nvim" }, -- Treesitter @@ -37,4 +24,24 @@ return { }, -- "p00f/nvim-ts-rainbow" -- "nvim-treesitter/playground" + { "neovim/nvim-lspconfig" }, + { "williamboman/mason.nvim" }, + { "williamboman/mason-lspconfig.nvim" }, + { + "hrsh7th/nvim-cmp", + dependencies = { + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-path', + 'hrsh7th/cmp-cmdline', + 'L3MON4D3/LuaSnip', + 'saadparwaiz1/cmp_luasnip', + 'hrsh7th/cmp-vsnip', + 'hrsh7th/vim-vsnip', + 'rafamadriz/friendly-snippets', + } + }, + { 'mfussenegger/nvim-lint', }, + { 'mfussenegger/nvim-dap' }, + { 'mhartington/formatter.nvim' } } diff --git a/lua/plugins/cmp-settings.lua b/lua/plugins/cmp-settings.lua new file mode 100644 index 00000000..32c80c76 --- /dev/null +++ b/lua/plugins/cmp-settings.lua @@ -0,0 +1,75 @@ +-- ~/.config/nvim/lua/plugins/cmp.lua +return { + { + "hrsh7th/nvim-cmp", + dependencies = { + "L3MON4D3/LuaSnip", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + -- Optional extras: + -- "petertriho/cmp-git", + }, + config = function() + local cmp = require("cmp") + local luasnip = require("luasnip") + + -- Load friendly snippets + require("luasnip.loaders.from_vscode").lazy_load() + + cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + window = { + completion = cmp.config.window.bordered(), + -- documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = true }), + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + }, { + { name = "buffer" }, + }), + }) + + -- Git commits + cmp.setup.filetype("gitcommit", { + sources = cmp.config.sources({ + { name = "git" }, -- if using petertriho/cmp-git + }, { + { name = "buffer" }, + }), + }) + + -- Search (/ and ?) + cmp.setup.cmdline({ "/", "?" }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "buffer" }, + }, + }) + + -- Command mode (:) + cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = "path" }, + }, { + { name = "cmdline" }, + }), + }) + end, + }, +} + diff --git a/lua/plugins/formatter.lua b/lua/plugins/formatter.lua new file mode 100644 index 00000000..0602a993 --- /dev/null +++ b/lua/plugins/formatter.lua @@ -0,0 +1,43 @@ +return { + 'stevearc/conform.nvim', + event = { 'BufWritePre' }, + cmd = { 'ConformInfo' }, + keys = { + { + -- Customize or remove this keymap to your liking + 'f', + function() + require('conform').format { async = true } + end, + mode = 'n', + desc = 'Format buffer', + }, + }, + -- This will provide type hinting with LuaLS + ---@module "conform" + ---@type conform.setupOpts + opts = { + -- Define your formatters + formatters_by_ft = { + lua = { 'stylua' }, + python = { 'isort', 'black' }, + javascript = { 'prettierd', 'prettier', stop_after_first = true }, + }, + -- Set default options + default_format_opts = { + lsp_format = 'fallback', + }, + -- Set up format-on-save + format_on_save = { timeout_ms = 500 }, + -- Customize formatters + formatters = { + shfmt = { + prepend_args = { '-i', '2' }, + }, + }, + }, + init = function() + -- If you want the formatexpr, here is the place to set it + vim.o.formatexpr = "v:lua.require'conform'.formatexpr()" + end, +} diff --git a/lua/plugins/lsp-settings.lua b/lua/plugins/lsp-settings.lua new file mode 100644 index 00000000..2ac0bc5b --- /dev/null +++ b/lua/plugins/lsp-settings.lua @@ -0,0 +1,69 @@ +-- ~/.config/nvim/lua/plugins/custom-lsp.lua +return { + { + "neovim/nvim-lspconfig", + dependencies = { + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + "hrsh7th/cmp-nvim-lsp", + }, + config = function() + -- Setup Mason + require("mason").setup() + require("mason-lspconfig").setup() + + -- LSPs to enable + -- local servers = { + -- "lua_ls", + -- "ols", + -- "zls", + -- "clangd", + -- "jsonls", + -- "html", + -- "rust_analyzer", + -- "jdtls", + -- "eslint", + -- "pyright", + -- } + + local lspconfig = require("lspconfig") + local capabilities = require("cmp_nvim_lsp").default_capabilities() + + -- for _, server in ipairs(servers) do + -- lspconfig[server].setup({ + -- capabilities = capabilities, + -- }) + -- end + + -- Autocommand for keymaps + vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("UserLspConfig", {}), + callback = function(ev) + local map = function(keys, func, desc) + vim.keymap.set("n", keys, func, { buffer = ev.buf, desc = "Lsp: " .. desc }) + end + + local tele = require("telescope.builtin") + + map("gd", tele.lsp_definitions, "Goto Definition") + map("fs", tele.lsp_document_symbols, "Doc Symbols") + map("fS", tele.lsp_dynamic_workspace_symbols, "Dynamic Symbols") + map("ft", tele.lsp_type_definitions, "Goto Type") + map("fr", tele.lsp_references, "Goto References") + map("fi", tele.lsp_implementations, "Goto Impl") + + map("K", vim.lsp.buf.hover, "Hover Docs") + map("E", vim.diagnostic.open_float, "Diagnostics") + map("k", vim.lsp.buf.signature_help, "Signature Help") + map("rn", vim.lsp.buf.rename, "Rename") + map("ca", vim.lsp.buf.code_action, "Code Action") + map("wf", function() + vim.lsp.buf.format({ async = true }) + end, "Format") + + vim.keymap.set("v", "ca", vim.lsp.buf.code_action, { buffer = ev.buf, desc = "Lsp: Code Action" }) + end, + }) + end, + }, +} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua deleted file mode 100644 index 6f1b581c..00000000 --- a/lua/plugins/lsp.lua +++ /dev/null @@ -1,130 +0,0 @@ --- return { --- "mason-org/mason-lspconfig.nvim", --- opts = { --- ensure_installed = { "lua_ls", "rust_analyzer", "pyright" }, --- }, --- dependencies = { --- { "mason-org/mason.nvim", opts = {} }, --- "neovim/nvim-lspconfig", --- }, --- } -return { - "VonHeikemen/lsp-zero.nvim", - branch = "v2.x", - dependencies = { - -- LSP Support - { "neovim/nvim-lspconfig" }, -- Required - { -- Optional - "williamboman/mason.nvim", - build = function() - pcall(vim.cmd, "MasonUpdate") - end, - }, - { "williamboman/mason-lspconfig.nvim" }, -- Optional - - -- Autocompletion - { "hrsh7th/nvim-cmp" }, -- Required - { "hrsh7th/cmp-nvim-lsp" }, -- Required - { "L3MON4D3/LuaSnip" }, -- Required - { "rafamadriz/friendly-snippets" }, - { "hrsh7th/cmp-buffer" }, - { "hrsh7th/cmp-path" }, - { "hrsh7th/cmp-cmdline" }, - { "saadparwaiz1/cmp_luasnip" }, - }, - config = function() - local lsp = require("lsp-zero") - - lsp.on_attach(function(client, bufnr) - local opts = { buffer = bufnr, remap = false } - - vim.keymap.set("n", "gr", function() vim.lsp.buf.references() end, vim.tbl_deep_extend("force", opts, { desc = "LSP Goto Reference" })) - vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, vim.tbl_deep_extend("force", opts, { desc = "LSP Goto Definition" })) - vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, vim.tbl_deep_extend("force", opts, { desc = "LSP Hover" })) - vim.keymap.set("n", "vws", function() vim.lsp.buf.workspace_symbol() end, vim.tbl_deep_extend("force", opts, { desc = "LSP Workspace Symbol" })) - vim.keymap.set("n", "vd", function() vim.diagnostic.setloclist() end, vim.tbl_deep_extend("force", opts, { desc = "LSP Show Diagnostics" })) - vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, vim.tbl_deep_extend("force", opts, { desc = "Next Diagnostic" })) - vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, vim.tbl_deep_extend("force", opts, { desc = "Previous Diagnostic" })) - vim.keymap.set("n", "vca", function() vim.lsp.buf.code_action() end, vim.tbl_deep_extend("force", opts, { desc = "LSP Code Action" })) - vim.keymap.set("n", "vrr", function() vim.lsp.buf.references() end, vim.tbl_deep_extend("force", opts, { desc = "LSP References" })) - vim.keymap.set("n", "vrn", function() vim.lsp.buf.rename() end, vim.tbl_deep_extend("force", opts, { desc = "LSP Rename" })) - vim.keymap.set("i", "", function() vim.lsp.buf.signature_help() end, vim.tbl_deep_extend("force", opts, { desc = "LSP Signature Help" })) - end) - - require("mason").setup({}) - require("mason-lspconfig").setup({ - ensure_installed = { - "eslint", - "lua_ls", - "jsonls", - "html", - "tailwindcss", - -- "pylsp", - "dockerls", - "bashls", - "gopls", - "pyright", - }, - handlers = { - lsp.default_setup, - lua_ls = function() - local lua_opts = lsp.nvim_lua_ls() - require("lspconfig").lua_ls.setup(lua_opts) - end, - }, - }) - - local cmp_action = require("lsp-zero").cmp_action() - local cmp = require("cmp") - local cmp_select = { behavior = cmp.SelectBehavior.Select } - - require("luasnip.loaders.from_vscode").lazy_load() - - -- `/` cmdline setup. - cmp.setup.cmdline("/", { - mapping = cmp.mapping.preset.cmdline(), - sources = { - { name = "buffer" }, - }, - }) - - -- `:` cmdline setup. - cmp.setup.cmdline(":", { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ - { name = "path" }, - }, { - { - name = "cmdline", - option = { - ignore_cmds = { "Man", "!" }, - }, - }, - }), - }) - - cmp.setup({ - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, - sources = { - { name = "nvim_lsp" }, - { name = "luasnip", keyword_length = 2 }, - { name = "buffer", keyword_length = 3 }, - { name = "path" }, - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.select_prev_item(cmp_select), - [""] = cmp.mapping.select_next_item(cmp_select), - [""] = cmp.mapping.confirm({ select = true }), - [""] = cmp.mapping.complete(), - [""] = cmp_action.luasnip_jump_forward(), - [""] = cmp_action.luasnip_jump_backward(), - [""] = cmp_action.luasnip_supertab(), - [""] = cmp_action.luasnip_shift_supertab(), - }), - }) - end, -} diff --git a/lua/plugins/nvim-cmp.lua b/lua/plugins/nvim-cmp.lua deleted file mode 100644 index 8002641e..00000000 --- a/lua/plugins/nvim-cmp.lua +++ /dev/null @@ -1,61 +0,0 @@ -return { - "hrsh7th/nvim-cmp", - event = "InsertEnter", - dependencies = { - "hrsh7th/cmp-buffer", -- Source for text in buffer - "hrsh7th/cmp-path", -- Source for file system paths - { - "L3MON4D3/LuaSnip", -- Snippet Engine - version = "v2.*", - build = "make install_jsregexp", -- Allow lsp-snippet-transformations - }, - "rafamadriz/friendly-snippets", -- Preconfigured snippets for different languages - "onsails/lspkind.nvim", -- VS-Code like pictograms - }, - config = function() - local cmp = require("cmp") - local lspkind = require("lspkind") - local luasnip = require("luasnip") - - require("luasnip.loaders.from_vscode").lazy_load() -- Required for friendly-snippets to work - - -- Settings for the appearance of the completion window - vim.api.nvim_set_hl(0, "CmpNormal", { bg = "#000000", fg = "#ffffff" }) - vim.api.nvim_set_hl(0, "CmpSelect", { bg = "#000000", fg = "#b5010f" }) - vim.api.nvim_set_hl(0, "CmpBorder", { bg = "#000000", fg = "#b5010f" }) - - cmp.setup({ - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.close(), - [""] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }), - }), - sources = cmp.config.sources({ - { name = "nvim_lsp" }, - { name = "luasnip" }, - { name = "buffer" }, - { name = "path" }, - }), - window = { - completion = { - border = "rounded", - winhighlight = "Normal:CmpNormal,CursorLine:CmpSelect,FloatBorder:CmpBorder", - } - }, - }) - vim.cmd([[ - set completeopt=menuone,noinsert,noselect - highlight! default link CmpItemKind CmpItemMenuDefault - ]]) - end, -} diff --git a/tester.py b/tester.py index d6a2c41a..aa93b791 100644 --- a/tester.py +++ b/tester.py @@ -1,20 +1,18 @@ items = [1, 2, 3] -print([x**2 for x in items]) -print([x**3 for x in items]) for i in items: print(i) def myfunc(x: int) -> str: - 'this is a docstring yuhhh' + "this is a docstring yuhhh" return f"this is my num {x}" def myfunc2(): - pass + pass -print(myfunc(2)) -print(myfunc(3)) -print(myfunc(5)) +print(myfunc(4)) + +print(myfunc(5))