From 61d3aec608ad080dbf0f019a082793539a9127f3 Mon Sep 17 00:00:00 2001 From: "RingOfStorms (Joshua Bell)" Date: Thu, 2 May 2024 12:33:00 -0500 Subject: [PATCH] formatting/linting added for lua/ts --- README.md | 4 + buffer_layout.json | 1 - flake.lock | 495 +------------------------ flake.nix | 184 +++------ init.lua | 129 +++---- lua/autocommands.lua | 12 +- lua/keymaps.lua | 8 +- lua/options.lua | 2 +- lua/plugins/color_picker.lua | 1 + lua/plugins/editor_lua_line.lua | 6 +- lua/plugins/editor_tabwidth_sleuth.lua | 5 + lua/plugins/formatter.lua | 30 ++ lua/plugins/git_signs.lua | 1 - lua/plugins/indent_indicators.lua | 5 +- lua/plugins/lint.lua | 139 +++++++ lua/plugins/telescope.lua | 19 +- lua/tools/quick-fix.lua | 5 +- lua/util.lua | 2 +- 18 files changed, 338 insertions(+), 710 deletions(-) delete mode 100644 buffer_layout.json create mode 100644 lua/plugins/editor_tabwidth_sleuth.lua create mode 100644 lua/plugins/formatter.lua create mode 100644 lua/plugins/lint.lua diff --git a/README.md b/README.md index b20f766..6e087f9 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,20 @@ # NVIM config Goals: + - Works with or without nix - LSP integration with the current project's settings if available ## Running ### With Nix + ```sh nix run "." ``` ### Without Nix + - Must have all required programs installed and available on path - neovim >= 0.5 - Evertying listed in flake.nix `runtime dependencies` variable near the top of the file @@ -72,3 +75,4 @@ FUTURE - check out - https://github.com/onsails/lspkind.nvim - https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-align.md + - https://github.com/tpope/vim-abolish diff --git a/buffer_layout.json b/buffer_layout.json deleted file mode 100644 index b64618d..0000000 --- a/buffer_layout.json +++ /dev/null @@ -1 +0,0 @@ -[{"buf": 1, "col": 0, "row": 0, "bufname": "/home/josh/projects/nvim/README.md", "win": 1000, "width": 68, "height": 48}, {"buf": 10, "col": 69, "row": 0, "bufname": "/home/josh/projects/nvim/lua/util.lua", "win": 1001, "width": 68, "height": 12}, {"buf": 19, "col": 69, "row": 13, "bufname": "/home/josh/projects/nvim/init.lua", "win": 1002, "width": 68, "height": 35}] \ No newline at end of file diff --git a/flake.lock b/flake.lock index 1f849e3..fc96465 100644 --- a/flake.lock +++ b/flake.lock @@ -33,102 +33,6 @@ "type": "indirect" } }, - "nvim_plugin-Almo7aya/openingh.nvim": { - "flake": false, - "locked": { - "lastModified": 1710100117, - "narHash": "sha256-xGQdEO8Fjh4Tmv5WnYJFqaitH0wZnLlbYstwqsO0Oeg=", - "owner": "Almo7aya", - "repo": "openingh.nvim", - "rev": "613c18967d42202f3e2a9ac788caf62a402e7c1a", - "type": "github" - }, - "original": { - "owner": "Almo7aya", - "repo": "openingh.nvim", - "type": "github" - } - }, - "nvim_plugin-JoosepAlviste/nvim-ts-context-commentstring": { - "flake": false, - "locked": { - "lastModified": 1713335068, - "narHash": "sha256-MnlhT17hR+tewbtLjaecxXxV1/ywzoqCL5MNtZsVYYk=", - "owner": "JoosepAlviste", - "repo": "nvim-ts-context-commentstring", - "rev": "a6382f744f584bbf71d0a563af789af7190aabda", - "type": "github" - }, - "original": { - "owner": "JoosepAlviste", - "repo": "nvim-ts-context-commentstring", - "type": "github" - } - }, - "nvim_plugin-MunifTanjim/nui.nvim": { - "flake": false, - "locked": { - "lastModified": 1710740032, - "narHash": "sha256-Zr5CNx6BIM6naCXW8YBc/Oj1qOtWV/3tuMoaaZjoSZA=", - "owner": "MunifTanjim", - "repo": "nui.nvim", - "rev": "cbd2668414331c10039278f558630ed19b93e69b", - "type": "github" - }, - "original": { - "owner": "MunifTanjim", - "repo": "nui.nvim", - "type": "github" - } - }, - "nvim_plugin-Pocco81/auto-save.nvim": { - "flake": false, - "locked": { - "lastModified": 1667329943, - "narHash": "sha256-bWGil73YiCKZEaY7IuUOIU4Q7k7qCMjSeQ4I+cAVe44=", - "owner": "Pocco81", - "repo": "auto-save.nvim", - "rev": "979b6c82f60cfa80f4cf437d77446d0ded0addf0", - "type": "github" - }, - "original": { - "owner": "Pocco81", - "repo": "auto-save.nvim", - "type": "github" - } - }, - "nvim_plugin-RRethy/vim-illuminate": { - "flake": false, - "locked": { - "lastModified": 1713467568, - "narHash": "sha256-o0D1edrsHkaljrzBFZXjdxiK/5ziCGJxM/kYNJgBI1E=", - "owner": "RRethy", - "repo": "vim-illuminate", - "rev": "e522e0dd742a83506db0a72e1ced68c9c130f185", - "type": "github" - }, - "original": { - "owner": "RRethy", - "repo": "vim-illuminate", - "type": "github" - } - }, - "nvim_plugin-catppuccin/nvim": { - "flake": false, - "locked": { - "lastModified": 1711706907, - "narHash": "sha256-GQjxE8lQj52pheJtHCS+9v2lsJY7wMj2IXVCoNRmQSQ=", - "owner": "catppuccin", - "repo": "nvim", - "rev": "aebe43db9cb26e1c70fc5b2fd4158169c405e720", - "type": "github" - }, - "original": { - "owner": "catppuccin", - "repo": "nvim", - "type": "github" - } - }, "nvim_plugin-chrisgrieser/nvim-early-retirement": { "flake": false, "locked": { @@ -161,409 +65,12 @@ "type": "github" } }, - "nvim_plugin-folke/lazy.nvim": { - "flake": false, - "locked": { - "lastModified": 1711740527, - "narHash": "sha256-MyJfQS80so7COsN87aGtd6DSrDKUme6SaFGWpaQ1ZHk=", - "owner": "folke", - "repo": "lazy.nvim", - "rev": "31ddbea7c10b6920c9077b66c97951ca8682d5c8", - "type": "github" - }, - "original": { - "owner": "folke", - "repo": "lazy.nvim", - "type": "github" - } - }, - "nvim_plugin-folke/noice.nvim": { - "flake": false, - "locked": { - "lastModified": 1711471279, - "narHash": "sha256-y6gHNkWVsIuwBf7MblCTKTZSqjGDxqeFeQZWexzwk94=", - "owner": "folke", - "repo": "noice.nvim", - "rev": "0cbe3f88d038320bdbda3c4c5c95f43a13c3aa12", - "type": "github" - }, - "original": { - "owner": "folke", - "repo": "noice.nvim", - "type": "github" - } - }, - "nvim_plugin-folke/which-key.nvim": { - "flake": false, - "locked": { - "lastModified": 1697801635, - "narHash": "sha256-uvghPj/teWrRMm09Gh8iQ/LV2nYJw0lmoiZK6L4+1cY=", - "owner": "folke", - "repo": "which-key.nvim", - "rev": "4433e5ec9a507e5097571ed55c02ea9658fb268a", - "type": "github" - }, - "original": { - "owner": "folke", - "repo": "which-key.nvim", - "type": "github" - } - }, - "nvim_plugin-johmsalas/text-case.nvim": { - "flake": false, - "locked": { - "lastModified": 1708695777, - "narHash": "sha256-ROvmPMB3lMeehFtL7EsHGFkE+ZD9r/ines7yDmB+7Ag=", - "owner": "johmsalas", - "repo": "text-case.nvim", - "rev": "d62c63a4e9a996c7321885937ab89920fca2c1c8", - "type": "github" - }, - "original": { - "owner": "johmsalas", - "repo": "text-case.nvim", - "type": "github" - } - }, - "nvim_plugin-lewis6991/gitsigns.nvim": { - "flake": false, - "locked": { - "lastModified": 1714557033, - "narHash": "sha256-IpYpya8z6e8t9Lf/ZFx97HsnVwaYLZ44D5rCKvOyybA=", - "owner": "lewis6991", - "repo": "gitsigns.nvim", - "rev": "9cafac31a091267838e1e90fd6e083d37611f516", - "type": "github" - }, - "original": { - "owner": "lewis6991", - "repo": "gitsigns.nvim", - "type": "github" - } - }, - "nvim_plugin-lnc3l0t/glow.nvim": { - "flake": false, - "locked": { - "lastModified": 1693233815, - "narHash": "sha256-vdlwkIK2EkFviJmSiOqPWvc15xqJ9F2gHCC4ObJ5Qjk=", - "owner": "lnc3l0t", - "repo": "glow.nvim", - "rev": "5b38fb7b6e806cac62707a4aba8c10c5f14d5bb5", - "type": "github" - }, - "original": { - "owner": "lnc3l0t", - "repo": "glow.nvim", - "type": "github" - } - }, - "nvim_plugin-lukas-reineke/indent-blankline.nvim": { - "flake": false, - "locked": { - "lastModified": 1710388427, - "narHash": "sha256-Xp8ZQBz0in2MX3l0bnLUsSbH0lDPE+QvdmFpBFry5yY=", - "owner": "lukas-reineke", - "repo": "indent-blankline.nvim", - "rev": "3d08501caef2329aba5121b753e903904088f7e6", - "type": "github" - }, - "original": { - "owner": "lukas-reineke", - "repo": "indent-blankline.nvim", - "type": "github" - } - }, - "nvim_plugin-mbbill/undotree": { - "flake": false, - "locked": { - "lastModified": 1713305700, - "narHash": "sha256-UIroW89ALMRdxSkNGU2VPeuXJxR+25wJ+AakRcjwx/s=", - "owner": "mbbill", - "repo": "undotree", - "rev": "56c684a805fe948936cda0d1b19505b84ad7e065", - "type": "github" - }, - "original": { - "owner": "mbbill", - "repo": "undotree", - "type": "github" - } - }, - "nvim_plugin-nvim-lua/plenary.nvim": { - "flake": false, - "locked": { - "lastModified": 1714083960, - "narHash": "sha256-vy0MXEoSM4rvYpfwbc2PnilvMOA30Urv0FAxjXuvqQ8=", - "owner": "nvim-lua", - "repo": "plenary.nvim", - "rev": "08e301982b9a057110ede7a735dd1b5285eb341f", - "type": "github" - }, - "original": { - "owner": "nvim-lua", - "repo": "plenary.nvim", - "type": "github" - } - }, - "nvim_plugin-nvim-lualine/lualine.nvim": { - "flake": false, - "locked": { - "lastModified": 1712310396, - "narHash": "sha256-WcH2dWdRDgMkwBQhcgT+Z/ArMdm+VbRhmQftx4t2kNI=", - "owner": "nvim-lualine", - "repo": "lualine.nvim", - "rev": "0a5a66803c7407767b799067986b4dc3036e1983", - "type": "github" - }, - "original": { - "owner": "nvim-lualine", - "repo": "lualine.nvim", - "type": "github" - } - }, - "nvim_plugin-nvim-telescope/telescope-fzf-native.nvim": { - "flake": false, - "locked": { - "lastModified": 1709647247, - "narHash": "sha256-rycebls3g0JCHM2+aG7xlJnX7ZPowqviaLbQrFSdflM=", - "owner": "nvim-telescope", - "repo": "telescope-fzf-native.nvim", - "rev": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27", - "type": "github" - }, - "original": { - "owner": "nvim-telescope", - "repo": "telescope-fzf-native.nvim", - "type": "github" - } - }, - "nvim_plugin-nvim-telescope/telescope-ui-select.nvim": { - "flake": false, - "locked": { - "lastModified": 1701723223, - "narHash": "sha256-YRhNmmG4gx9Ht8JwjQfbTjJyTHEuZmtP6lqnhOsk8bE=", - "owner": "nvim-telescope", - "repo": "telescope-ui-select.nvim", - "rev": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2", - "type": "github" - }, - "original": { - "owner": "nvim-telescope", - "repo": "telescope-ui-select.nvim", - "type": "github" - } - }, - "nvim_plugin-nvim-telescope/telescope.nvim": { - "flake": false, - "locked": { - "lastModified": 1714530387, - "narHash": "sha256-lQl0UwUfHhPjJHWbNTR10NB+GATJUiD3lRESEdduX7w=", - "owner": "nvim-telescope", - "repo": "telescope.nvim", - "rev": "2d0d057791854decb2c9b6a0b52d43f3900dff40", - "type": "github" - }, - "original": { - "owner": "nvim-telescope", - "repo": "telescope.nvim", - "type": "github" - } - }, - "nvim_plugin-nvim-tree/nvim-tree.lua": { - "flake": false, - "locked": { - "lastModified": 1714440771, - "narHash": "sha256-yLWb3aKsab3Cqbp3RgP0maiLOQWtxbUdnkLy7sQygx0=", - "owner": "nvim-tree", - "repo": "nvim-tree.lua", - "rev": "347e1eb35264677f66a79466bb5e3d111968e12c", - "type": "github" - }, - "original": { - "owner": "nvim-tree", - "repo": "nvim-tree.lua", - "type": "github" - } - }, - "nvim_plugin-nvim-tree/nvim-web-devicons": { - "flake": false, - "locked": { - "lastModified": 1714371374, - "narHash": "sha256-gc+8GgFSM87dbcYUW8d9If3qY80xJMmy48vnVezNLPk=", - "owner": "nvim-tree", - "repo": "nvim-web-devicons", - "rev": "794bba734ec95eaff9bb82fbd112473be2087283", - "type": "github" - }, - "original": { - "owner": "nvim-tree", - "repo": "nvim-web-devicons", - "type": "github" - } - }, - "nvim_plugin-preservim/nerdcommenter": { - "flake": false, - "locked": { - "lastModified": 1702928950, - "narHash": "sha256-zQy5VN2w9Hqo0Is7Yp2fm1WvBV6QNJwhHm0eozh69TI=", - "owner": "preservim", - "repo": "nerdcommenter", - "rev": "e361a44230860d616f799a337bc58f5218ab6e9c", - "type": "github" - }, - "original": { - "owner": "preservim", - "repo": "nerdcommenter", - "type": "github" - } - }, - "nvim_plugin-rcarriga/nvim-notify": { - "flake": false, - "locked": { - "lastModified": 1708161547, - "narHash": "sha256-xJYPOX4YLcWojMCdP1RO22/7FMrbcBQxqxrcVCE2TrU=", - "owner": "rcarriga", - "repo": "nvim-notify", - "rev": "5371f4bfc1f6d3adf4fe9d62cd3a9d44356bfd15", - "type": "github" - }, - "original": { - "owner": "rcarriga", - "repo": "nvim-notify", - "type": "github" - } - }, - "nvim_plugin-rmagatti/auto-session": { - "flake": false, - "locked": { - "lastModified": 1713075135, - "narHash": "sha256-wu/utBYr4o4BenybAumDxBTERBkRkcR1QzlfmnVbOTQ=", - "owner": "rmagatti", - "repo": "auto-session", - "rev": "9e0a169b6fce8791278abbd110717b921afe634d", - "type": "github" - }, - "original": { - "owner": "rmagatti", - "repo": "auto-session", - "type": "github" - } - }, - "nvim_plugin-sindrets/diffview.nvim": { - "flake": false, - "locked": { - "lastModified": 1700506468, - "narHash": "sha256-3EdnBUka9Rh5Brl6TWpN6GlD9z32mmY3Ip+wyiKob/8=", - "owner": "sindrets", - "repo": "diffview.nvim", - "rev": "3dc498c9777fe79156f3d32dddd483b8b3dbd95f", - "type": "github" - }, - "original": { - "owner": "sindrets", - "repo": "diffview.nvim", - "type": "github" - } - }, - "nvim_plugin-tpope/vim-surround": { - "flake": false, - "locked": { - "lastModified": 1666730476, - "narHash": "sha256-DZE5tkmnT+lAvx/RQHaDEgEJXRKsy56KJY919xiH1lE=", - "owner": "tpope", - "repo": "vim-surround", - "rev": "3d188ed2113431cf8dac77be61b842acb64433d9", - "type": "github" - }, - "original": { - "owner": "tpope", - "repo": "vim-surround", - "type": "github" - } - }, - "nvim_plugin-uga-rosa/ccc.nvim": { - "flake": false, - "locked": { - "lastModified": 1714299582, - "narHash": "sha256-QRq9hQF5vLnOTzQGbOWC2ykMdMsQDlDlb6XC17dJG7Q=", - "owner": "uga-rosa", - "repo": "ccc.nvim", - "rev": "f388f1981d222967c741fe9927edf9ba5fa3bcbe", - "type": "github" - }, - "original": { - "owner": "uga-rosa", - "repo": "ccc.nvim", - "type": "github" - } - }, - "nvim_plugin-voldikss/vim-floaterm": { - "flake": false, - "locked": { - "lastModified": 1712535773, - "narHash": "sha256-wIgcBcdxJsT+qrsC5Boj6hp0xpp5gFeQFhK7yyC5a1o=", - "owner": "voldikss", - "repo": "vim-floaterm", - "rev": "4e28c8dd0271e10a5f55142fb6fe9b1599ee6160", - "type": "github" - }, - "original": { - "owner": "voldikss", - "repo": "vim-floaterm", - "type": "github" - } - }, - "nvim_plugin-windwp/nvim-ts-autotag": { - "flake": false, - "locked": { - "lastModified": 1707265789, - "narHash": "sha256-cPIEIjcYxX3ZkOyou2mYlHMdhBxCoVTpJVXZtiWe9Ks=", - "owner": "windwp", - "repo": "nvim-ts-autotag", - "rev": "531f48334c422222aebc888fd36e7d109cb354cd", - "type": "github" - }, - "original": { - "owner": "windwp", - "repo": "nvim-ts-autotag", - "type": "github" - } - }, "root": { "inputs": { "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", - "nvim_plugin-Almo7aya/openingh.nvim": "nvim_plugin-Almo7aya/openingh.nvim", - "nvim_plugin-JoosepAlviste/nvim-ts-context-commentstring": "nvim_plugin-JoosepAlviste/nvim-ts-context-commentstring", - "nvim_plugin-MunifTanjim/nui.nvim": "nvim_plugin-MunifTanjim/nui.nvim", - "nvim_plugin-Pocco81/auto-save.nvim": "nvim_plugin-Pocco81/auto-save.nvim", - "nvim_plugin-RRethy/vim-illuminate": "nvim_plugin-RRethy/vim-illuminate", - "nvim_plugin-catppuccin/nvim": "nvim_plugin-catppuccin/nvim", "nvim_plugin-chrisgrieser/nvim-early-retirement": "nvim_plugin-chrisgrieser/nvim-early-retirement", - "nvim_plugin-declancm/cinnamon.nvim": "nvim_plugin-declancm/cinnamon.nvim", - "nvim_plugin-folke/lazy.nvim": "nvim_plugin-folke/lazy.nvim", - "nvim_plugin-folke/noice.nvim": "nvim_plugin-folke/noice.nvim", - "nvim_plugin-folke/which-key.nvim": "nvim_plugin-folke/which-key.nvim", - "nvim_plugin-johmsalas/text-case.nvim": "nvim_plugin-johmsalas/text-case.nvim", - "nvim_plugin-lewis6991/gitsigns.nvim": "nvim_plugin-lewis6991/gitsigns.nvim", - "nvim_plugin-lnc3l0t/glow.nvim": "nvim_plugin-lnc3l0t/glow.nvim", - "nvim_plugin-lukas-reineke/indent-blankline.nvim": "nvim_plugin-lukas-reineke/indent-blankline.nvim", - "nvim_plugin-mbbill/undotree": "nvim_plugin-mbbill/undotree", - "nvim_plugin-nvim-lua/plenary.nvim": "nvim_plugin-nvim-lua/plenary.nvim", - "nvim_plugin-nvim-lualine/lualine.nvim": "nvim_plugin-nvim-lualine/lualine.nvim", - "nvim_plugin-nvim-telescope/telescope-fzf-native.nvim": "nvim_plugin-nvim-telescope/telescope-fzf-native.nvim", - "nvim_plugin-nvim-telescope/telescope-ui-select.nvim": "nvim_plugin-nvim-telescope/telescope-ui-select.nvim", - "nvim_plugin-nvim-telescope/telescope.nvim": "nvim_plugin-nvim-telescope/telescope.nvim", - "nvim_plugin-nvim-tree/nvim-tree.lua": "nvim_plugin-nvim-tree/nvim-tree.lua", - "nvim_plugin-nvim-tree/nvim-web-devicons": "nvim_plugin-nvim-tree/nvim-web-devicons", - "nvim_plugin-preservim/nerdcommenter": "nvim_plugin-preservim/nerdcommenter", - "nvim_plugin-rcarriga/nvim-notify": "nvim_plugin-rcarriga/nvim-notify", - "nvim_plugin-rmagatti/auto-session": "nvim_plugin-rmagatti/auto-session", - "nvim_plugin-sindrets/diffview.nvim": "nvim_plugin-sindrets/diffview.nvim", - "nvim_plugin-tpope/vim-surround": "nvim_plugin-tpope/vim-surround", - "nvim_plugin-uga-rosa/ccc.nvim": "nvim_plugin-uga-rosa/ccc.nvim", - "nvim_plugin-voldikss/vim-floaterm": "nvim_plugin-voldikss/vim-floaterm", - "nvim_plugin-windwp/nvim-ts-autotag": "nvim_plugin-windwp/nvim-ts-autotag" + "nvim_plugin-declancm/cinnamon.nvim": "nvim_plugin-declancm/cinnamon.nvim" } }, "systems": { diff --git a/flake.nix b/flake.nix index c1bb302..ddbb493 100644 --- a/flake.nix +++ b/flake.nix @@ -5,132 +5,18 @@ nixpkgs.url = "nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; - # Names should always be `nvim_plugin-[lazy plugin name]` - "nvim_plugin-folke/lazy.nvim" = { - url = "github:folke/lazy.nvim"; - flake = false; - }; - "nvim_plugin-nvim-lua/plenary.nvim" = { - url = "github:nvim-lua/plenary.nvim"; - flake = false; - }; - "nvim_plugin-catppuccin/nvim" = { - url = "github:catppuccin/nvim"; - flake = false; - }; - "nvim_plugin-Pocco81/auto-save.nvim" = { - url = "github:Pocco81/auto-save.nvim"; - flake = false; - }; + # Only need to add plugins as flake inputs if they are: + # - Missing in nixpkgs + # - We want to pin a specific version diverging from nixpkgs channel "nvim_plugin-chrisgrieser/nvim-early-retirement" = { url = "github:chrisgrieser/nvim-early-retirement"; flake = false; }; - "nvim_plugin-MunifTanjim/nui.nvim" = { - url = "github:MunifTanjim/nui.nvim"; - flake = false; - }; - "nvim_plugin-rcarriga/nvim-notify" = { - url = "github:rcarriga/nvim-notify"; - flake = false; - }; - "nvim_plugin-folke/noice.nvim" = { - url = "github:folke/noice.nvim"; - flake = false; - }; "nvim_plugin-declancm/cinnamon.nvim" = { url = "github:declancm/cinnamon.nvim"; flake = false; }; - "nvim_plugin-nvim-lualine/lualine.nvim" = { - url = "github:nvim-lualine/lualine.nvim"; - flake = false; - }; - "nvim_plugin-folke/which-key.nvim" = { - url = "github:folke/which-key.nvim"; - flake = false; - }; - "nvim_plugin-nvim-telescope/telescope.nvim" = { - url = "github:nvim-telescope/telescope.nvim"; - flake = false; - }; - "nvim_plugin-nvim-telescope/telescope-fzf-native.nvim" = { - url = "github:nvim-telescope/telescope-fzf-native.nvim"; - flake = false; - }; - "nvim_plugin-nvim-telescope/telescope-ui-select.nvim" = { - url = "github:nvim-telescope/telescope-ui-select.nvim"; - flake = false; - }; - "nvim_plugin-JoosepAlviste/nvim-ts-context-commentstring" = { - url = "github:JoosepAlviste/nvim-ts-context-commentstring"; - flake = false; - }; - "nvim_plugin-preservim/nerdcommenter" = { - url = "github:preservim/nerdcommenter"; - flake = false; - }; - "nvim_plugin-windwp/nvim-ts-autotag" = { - url = "github:windwp/nvim-ts-autotag"; - flake = false; - }; - "nvim_plugin-rmagatti/auto-session" = { - url = "github:rmagatti/auto-session"; - flake = false; - }; - "nvim_plugin-nvim-tree/nvim-web-devicons" = { - url = "github:nvim-tree/nvim-web-devicons"; - flake = false; - }; - "nvim_plugin-nvim-tree/nvim-tree.lua" = { - url = "github:nvim-tree/nvim-tree.lua"; - flake = false; - }; - "nvim_plugin-uga-rosa/ccc.nvim" = { - url = "github:uga-rosa/ccc.nvim"; - flake = false; - }; - "nvim_plugin-voldikss/vim-floaterm" = { - url = "github:voldikss/vim-floaterm"; - flake = false; - }; - "nvim_plugin-lewis6991/gitsigns.nvim" = { - url = "github:lewis6991/gitsigns.nvim"; - flake = false; - }; - "nvim_plugin-sindrets/diffview.nvim" = { - url = "github:sindrets/diffview.nvim"; - flake = false; - }; - "nvim_plugin-RRethy/vim-illuminate" = { - url = "github:RRethy/vim-illuminate"; - flake = false; - }; - "nvim_plugin-lukas-reineke/indent-blankline.nvim" = { - url = "github:lukas-reineke/indent-blankline.nvim"; - flake = false; - }; - "nvim_plugin-lnc3l0t/glow.nvim" = { - url = "github:lnc3l0t/glow.nvim"; - flake = false; - }; - "nvim_plugin-Almo7aya/openingh.nvim" = { - url = "github:Almo7aya/openingh.nvim"; - flake = false; - }; - "nvim_plugin-tpope/vim-surround" = { - url = "github:tpope/vim-surround"; - flake = false; - }; - "nvim_plugin-johmsalas/text-case.nvim" = { - url = "github:johmsalas/text-case.nvim"; - flake = false; - }; - "nvim_plugin-mbbill/undotree" = { - url = "github:mbbill/undotree"; - flake = false; - }; }; outputs = { self, nixpkgs, flake-utils, ... } @ inputs: @@ -140,8 +26,42 @@ pkgs = nixpkgs.legacyPackages.${system}; lib = nixpkgs.lib; - nonFlakePluginPaths = { - "nvim_plugin-nvim-treesitter/nvim-treesitter" = pkgs.vimPlugins.nvim-treesitter.withAllGrammars; + lazyPath = pkgs.vimPlugins.lazy-nvim; # inputs."nvim_plugin-folke/lazy.nvim" + # Plugins provided in nixpkgs, match the naming scheme above for keys + nixPkgsPlugins = with pkgs.vimPlugins; { + "nvim_plugin-folke/lazy.nvim" = lazyPath; + "nvim_plugin-nvim-treesitter/nvim-treesitter" = nvim-treesitter.withAllGrammars; + "nvim_plugin-nvim-lua/plenary.nvim" = plenary-nvim; + "nvim_plugin-catppuccin/nvim" = catppuccin-nvim; + "nvim_plugin-Pocco81/auto-save.nvim" = auto-save-nvim; + "nvim_plugin-MunifTanjim/nui.nvim" = nui-nvim; + "nvim_plugin-rcarriga/nvim-notify" = nvim-notify; + "nvim_plugin-folke/noice.nvim" = noice-nvim; + "nvim_plugin-nvim-lualine/lualine.nvim" = lualine-nvim; + "nvim_plugin-folke/which-key.nvim" = which-key-nvim; + "nvim_plugin-nvim-telescope/telescope.nvim" = telescope-nvim; + "nvim_plugin-nvim-telescope/telescope-fzf-native.nvim" = telescope-fzf-native-nvim; + "nvim_plugin-nvim-telescope/telescope-ui-select.nvim" = telescope-ui-select-nvim; + "nvim_plugin-JoosepAlviste/nvim-ts-context-commentstring" = nvim-ts-context-commentstring; + "nvim_plugin-preservim/nerdcommenter" = nerdcommenter; + "nvim_plugin-windwp/nvim-ts-autotag" = nvim-ts-autotag; + "nvim_plugin-rmagatti/auto-session" = auto-session; + "nvim_plugin-nvim-tree/nvim-web-devicons" = nvim-web-devicons; + "nvim_plugin-nvim-tree/nvim-tree.lua" = nvim-tree-lua; + "nvim_plugin-uga-rosa/ccc.nvim" = ccc-nvim; + "nvim_plugin-voldikss/vim-floaterm" = vim-floaterm; + "nvim_plugin-lewis6991/gitsigns.nvim" = gitsigns-nvim; + "nvim_plugin-sindrets/diffview.nvim" = diffview-nvim; + "nvim_plugin-RRethy/vim-illuminate" = vim-illuminate; + "nvim_plugin-lukas-reineke/indent-blankline.nvim" = indent-blankline-nvim; + "nvim_plugin-lnc3l0t/glow.nvim" = glow-nvim; + "nvim_plugin-Almo7aya/openingh.nvim" = openingh-nvim; + "nvim_plugin-tpope/vim-surround" = vim-surround; + "nvim_plugin-johmsalas/text-case.nvim" = text-case-nvim; + "nvim_plugin-mbbill/undotree" = undotree; + "nvim_plugin-tpope/vim-sleuth" = vim-sleuth; + "nvim_plugin-mfussenegger/nvim-lint" = nvim-lint; + "nvim_plugin-stevearc/conform.nvim" = conform-nvim; }; # This will be how we put any nix related stuff into our lua config luaNixGlobal = "NIX=" + lib.generators.toLua { multiline = false; indent = false; } ({ @@ -152,20 +72,28 @@ { "${name}" = inputs.${name}.outPath; } // dirs) - nonFlakePluginPaths + nixPkgsPlugins (builtins.filter (n: builtins.substring 0 12 n == "nvim_plugin-") (builtins.attrNames inputs)); }); runtimeDependencies = with pkgs; [ + # tools ripgrep # search fd # search fzf # search fuzzy - # curl # http requests tree-sitter glow # markdown renderer - # nodePackages.cspell + # linters + markdownlint-cli + luajitPackages.luacheck + biome # (t|s)j[x] + # formatters + stylua + nodePackages.prettier + # curl # http requests TODO + # nodePackages.cspell TODO ]; in { @@ -193,26 +121,24 @@ # Set the LAZY env path to the nix store, see init.lua for how it is used "--set" "LAZY" - "${inputs."nvim_plugin-folke/lazy.nvim"}" + "${lazyPath}" # Don't use default directories to not collide with another neovim config # All things at runtime should be deletable since we are using nix to handle downloads and bins. "--set" "XDG_CONFIG_HOME" - "/tmp/nvim_flaked/config" + "/tmp/nvim_flaked.USR_TODO/config" # TODO "--set" "XDG_DATA_HOME" - "/tmp/nvim_flaked/share" + "/tmp/nvim_flaked.USR_TODO/share" "--set" "XDG_RUNTIME_DIR" - "/tmp/nvim_flaked/run" + "/tmp/nvim_flaked.USR_TODO/run" "--set" "XDG_STATE_HOME" - "/tmp/nvim_flaked/state" + "/tmp/nvim_flaked.USR_TODO/state" ]; }); }; }); - } - diff --git a/init.lua b/init.lua index ea59429..b221cb9 100644 --- a/init.lua +++ b/init.lua @@ -1,11 +1,14 @@ if NIX then - -- Add my lua dir to the path. THIS IS NOT RECURSIVE! - -- For recursive we can do something like this: https://github.com/RingOfStorms/nvim/blob/0b833d555c69e88b450a10eec4e39a782bad1037/init.lua#L1-L17 - -- However this pollutes the path, it could be limited to just init files but this approach here one level deep is adequate for my own needs - package.path = package.path .. ";" .. NIX.storePath .. "/lua/?.lua" - package.path = package.path .. ";" .. NIX.storePath .. "/lua/?/init.lua" + -- Add my lua dir to the path. THIS IS NOT RECURSIVE! + -- For recursive we can do something like this: https://github.com/RingOfStorms/nvim/blob/0b833d555c69e88b450a10eec4e39a782bad1037/init.lua#L1-L17 + -- However this pollutes the path, it could be limited to just init files but this approach here one level deep is adequate for my own needs + package.path = package.path .. ";" .. NIX.storePath .. "/lua/?.lua" + package.path = package.path .. ";" .. NIX.storePath .. "/lua/?/init.lua" end +-- Compat stolen form LazyVim +vim.uv = vim.uv or vim.loop + U = require("util") -- NOTE global U[til] require("options") require("keymaps") @@ -13,75 +16,75 @@ require("keymaps") -- When using nix, it will set lazy via LAZY env variable. local lazypath = vim.env.LAZY or (vim.fn.stdpath("data") .. "/lazy/lazy.nvim") if not vim.loop.fs_stat(lazypath) then - if NIX then - error("LAZY environment variable to nix store was not found: " .. vim.env.LAZY) - return - end - -- For non nix systems, pull lazy stable to the normal XDG config path - local output = vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release - lazypath, - }) - if vim.api.nvim_get_vvar("shell_error") ~= 0 then - error("Error cloning lazy.nvim repository...\n\n" .. output) - end + if NIX then + error("LAZY environment variable to nix store was not found: " .. vim.env.LAZY) + return + end + -- For non nix systems, pull lazy stable to the normal XDG config path + local output = vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) + if vim.api.nvim_get_vvar("shell_error") ~= 0 then + error("Error cloning lazy.nvim repository...\n\n" .. output) + end end vim.opt.rtp:prepend(lazypath) -- Setup lazy local function ensure_table(object) - return type(object) == "table" and object or { object } + return type(object) == "table" and object or { object } end local function getSpec() - if NIX then - -- Convert plugins to use nix store, this auto sets the `dir` property for us on all plugins. - function convertPluginToNixStore(plugin) - local p = ensure_table(plugin) - local nixName = "nvim_plugin-" .. p[1] - if not NIX.pluginPaths[nixName] then - error("Plugin is missing in the nix store, ensure it is in the nix flake inputs: " .. p[1]) - end - p.dir = NIX.pluginPaths[nixName] - p.name = p.name or p[1] - p.url = "not_used_in_nix" - p.pin = true - if p.dependencies then - p.dependencies = ensure_table(p.dependencies) - for i, dep in ipairs(p.dependencies) do - p.dependencies[i] = convertPluginToNixStore(dep) - end - end - return p - end + if NIX then + -- Convert plugins to use nix store, this auto sets the `dir` property for us on all plugins. + function convertPluginToNixStore(plugin) + local p = ensure_table(plugin) + local nixName = "nvim_plugin-" .. p[1] + if not NIX.pluginPaths[nixName] then + error("Plugin is missing in the nix store, ensure it is in the nix flake inputs: " .. p[1]) + end + p.dir = NIX.pluginPaths[nixName] + p.name = p.name or p[1] + p.url = "not_used_in_nix" + p.pin = true + if p.dependencies then + p.dependencies = ensure_table(p.dependencies) + for i, dep in ipairs(p.dependencies) do + p.dependencies[i] = convertPluginToNixStore(dep) + end + end + return p + end - local plugins = {} - local plugins_path = debug.getinfo(2, "S").source:sub(2):match("(.*/)") .. "lua/plugins" - for _, file in ipairs(vim.fn.readdir(plugins_path, [[v:val =~ '\.lua$']])) do - local plugin = string.sub(file, 0, -5) - table.insert(plugins, convertPluginToNixStore(require("plugins." .. plugin))) - end - return plugins - else - -- TODO I want this to work in the nixos versionhttps://github.com/RingOfStorms/nvim/blob/nix-flake/init.lua#L39-L55 - -- but it is not resolving properly to the nix store. - -- Will revisit at some point, instead we manually pull them - -- in above with a directory scan. - return { { import = "plugins" } } - end + local plugins = {} + local plugins_path = debug.getinfo(2, "S").source:sub(2):match("(.*/)") .. "lua/plugins" + for _, file in ipairs(vim.fn.readdir(plugins_path, [[v:val =~ '\.lua$']])) do + local plugin = string.sub(file, 0, -5) + table.insert(plugins, convertPluginToNixStore(require("plugins." .. plugin))) + end + return plugins + else + -- TODO I want this to work in the nixos versionhttps://github.com/RingOfStorms/nvim/blob/nix-flake/init.lua#L39-L55 + -- but it is not resolving properly to the nix store. + -- Will revisit at some point, instead we manually pull them + -- in above with a directory scan. + return { { import = "plugins" } } + end end require("lazy").setup({ - spec = getSpec(), - change_detection = { - enabled = false, - }, + spec = getSpec(), + change_detection = { + enabled = false, + }, - defaults = { - lazy = true, - }, + defaults = { + lazy = true, + }, }) vim.cmd("colorscheme catppuccin") diff --git a/lua/autocommands.lua b/lua/autocommands.lua index 77d4b2a..41d0465 100644 --- a/lua/autocommands.lua +++ b/lua/autocommands.lua @@ -1,9 +1,10 @@ +local group = vim.api.nvim_create_augroup("myconfig-autocommands-group", { clear = true }); -- Highlight when yanking (copying) text -- Try it with `yap` in normal mode -- See `:help vim.highlight.on_yank()` vim.api.nvim_create_autocmd("TextYankPost", { + group = group, desc = "Highlight when yanking (copying) text", - group = vim.api.nvim_create_augroup("config-highlight-yank", { clear = true }), callback = function() vim.highlight.on_yank({ timeout = 300 }) end, @@ -11,24 +12,29 @@ vim.api.nvim_create_autocmd("TextYankPost", { -- TODO is there a better way for these? vim.api.nvim_create_autocmd("BufRead", { + group = group, pattern = ".env*", command = "set filetype=sh", }) vim.api.nvim_create_autocmd("BufRead", { + group = group, pattern = ".*rc", command = "set filetype=sh", }) vim.api.nvim_create_autocmd("BufRead", { + group = group, pattern = "Dockerfile.*", command = "set filetype=dockerfile", }) vim.api.nvim_create_autocmd("BufRead", { + group = group, pattern = "*.http", command = "set filetype=http", }) -- Auto exit insert mode whenever we switch screens vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, { + group = group, callback = function() if vim.bo.filetype ~= "TelescopePrompt" and vim.bo.filetype ~= nil and vim.bo.filetype ~= "" then vim.api.nvim_command("stopinsert") @@ -37,12 +43,14 @@ vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, { }) vim.api.nvim_create_autocmd("VimLeavePre", { + group = group, callback = function() vim.cmd("NvimTreeClose") -- Close all buffers with the 'httpResult' type + local close_types = { "httpResult", "noice", "help" } local buffers = vim.api.nvim_list_bufs() for _, bufnr in ipairs(buffers) do - if vim.bo[bufnr].filetype == "httpResult" then + if U.table_contains(close_types, vim.bo[bufnr].filetype) then vim.api.nvim_buf_delete(bufnr, { force = true }) end end diff --git a/lua/keymaps.lua b/lua/keymaps.lua index 586482f..07f3667 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -53,7 +53,7 @@ U.keymaps({ -- * if non empty buffer, we will simply open a new empty buffer unless -- it is in the close always list -- * if empty buffer, then we will quit this buffer - local close_always = { "quickfix", "help", "nofile", "httpResult" } + local close_always = { "quickfix", "help", "nofile", "noice", "httpResult" } if U.table_contains(close_always, vim.bo.buftype) or (vim.api.nvim_buf_line_count(0) == 1 and vim.api.nvim_buf_get_lines(0, 0, 1, -1)[1] == "") @@ -109,12 +109,6 @@ U.keymaps({ { "L", "tabnext", desc = "Move to next tab" }, -- LSP/IDE/etc TODO move to lsp config file - { - "l", - vim.lsp.buf.format, - desc = "Reformat file", - mode = nvx, - }, { "ld", vim.diagnostic.open_float, diff --git a/lua/options.lua b/lua/options.lua index ba69a2d..5c7f2bb 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -52,7 +52,7 @@ vim.opt.undofile = true -- See `:help 'list'` -- and `:help 'listchars'` vim.opt.list = true -vim.opt.listchars = { tab = "» ", trail = "·", nbsp = "␣", eol = "↴" } +vim.opt.listchars = { tab = "│ ", trail = "·", nbsp = "␣", eol = "↴" } -- TODO REVISIT IF I WANT THESE -- Search settings diff --git a/lua/plugins/color_picker.lua b/lua/plugins/color_picker.lua index 9b43986..a06d3a9 100644 --- a/lua/plugins/color_picker.lua +++ b/lua/plugins/color_picker.lua @@ -5,6 +5,7 @@ return { config = function(_, opts) require("ccc").setup(opts) vim.api.nvim_create_autocmd("BufRead", { + group = vim.api.nvim_create_augroup("myconfig-color-picker-group", { clear = true }), callback = function() vim.cmd.CccHighlighterEnable() end, diff --git a/lua/plugins/editor_lua_line.lua b/lua/plugins/editor_lua_line.lua index a8f6124..3af51f2 100644 --- a/lua/plugins/editor_lua_line.lua +++ b/lua/plugins/editor_lua_line.lua @@ -47,7 +47,7 @@ local function gitblame() if d then local ok, res = pcall(os.date, "%d %b %y", d.committer_time) - return d.committer .. " - " .. (ok and res or d.committer_time) + return d.committer:sub(1, 12) .. " - " .. (ok and res or d.committer_time) end return "" end @@ -121,11 +121,13 @@ return { }) end + local group = vim.api.nvim_create_augroup("myconfig-lua-line-group", { clear = true }) vim.api.nvim_create_autocmd("RecordingEnter", { + group = group, callback = ref, }) - vim.api.nvim_create_autocmd("RecordingLeave", { + group = group, callback = function() local timer = vim.loop.new_timer() timer:start(50, 0, vim.schedule_wrap(ref)) diff --git a/lua/plugins/editor_tabwidth_sleuth.lua b/lua/plugins/editor_tabwidth_sleuth.lua new file mode 100644 index 0000000..4b111c1 --- /dev/null +++ b/lua/plugins/editor_tabwidth_sleuth.lua @@ -0,0 +1,5 @@ +return { + -- This plugin automatically adjusts 'shiftwidth' and 'expandtab' heuristically based on the current file, or, in the case the current file is new, blank, or otherwise insufficient, by looking at other files of the same type in the current and parent directories. + "tpope/vim-sleuth", + event = "VeryLazy", +} diff --git a/lua/plugins/formatter.lua b/lua/plugins/formatter.lua new file mode 100644 index 0000000..3ce73e9 --- /dev/null +++ b/lua/plugins/formatter.lua @@ -0,0 +1,30 @@ +return { + "stevearc/conform.nvim", + opts = { + -- https://github.com/stevearc/conform.nvim?tab=readme-ov-file#setup + notify_on_error = true, + formatters_by_ft = { + lua = { "stylua" }, + typescript = { { "prettierd", "prettier" } }, + typescriptreact = { { "prettierd", "prettier" } }, + javascript = { { "prettierd", "prettier" } }, + javascriptreact = { { "prettierd", "prettier" } }, + }, + }, + keys = { + { + "l", + function() + require("conform").format({ async = true, lsp_fallback = true }, function(err, edited) + if edited then + print("Formatted!") + else + print("Nothing to format!") + end + end) + end, + mode = { "n", "v", "x" }, + desc = "Format buffer", + }, + }, +} diff --git a/lua/plugins/git_signs.lua b/lua/plugins/git_signs.lua index e564ec9..9d5f4d4 100644 --- a/lua/plugins/git_signs.lua +++ b/lua/plugins/git_signs.lua @@ -24,7 +24,6 @@ return { }, current_line_blame = true, current_line_blame_opts = { - delay = 0, virt_text = false, }, } diff --git a/lua/plugins/indent_indicators.lua b/lua/plugins/indent_indicators.lua index 23b5bed..498e8ab 100644 --- a/lua/plugins/indent_indicators.lua +++ b/lua/plugins/indent_indicators.lua @@ -26,9 +26,10 @@ return { }, }, }, - config = function(_, opts) + init = function() U.highlight("NonText", { fg = "#303030", gui = "nocombine" }) - + end, + config = function(_, opts) local hooks = require("ibl.hooks") hooks.register(hooks.type.HIGHLIGHT_SETUP, function() vim.api.nvim_set_hl(0, "IndentBlanklineIndent1", { fg = "#915053" }) diff --git a/lua/plugins/lint.lua b/lua/plugins/lint.lua new file mode 100644 index 0000000..b4b6656 --- /dev/null +++ b/lua/plugins/lint.lua @@ -0,0 +1,139 @@ +-- Stolen from LazyVim https://github.com/LazyVim/LazyVim/tree/f086bcde253c29be9a2b9c90b413a516f5d5a3b2/lua/lazyvim/plugins +return { + "mfussenegger/nvim-lint", + event = { "VeryLazy", "BufWritePost", "BufReadPost", "InsertLeave" }, + opts = { + -- Event to trigger linters + events = { "BufWritePost", "BufReadPost", "InsertLeave", "CursorHold", "CursorHoldI" }, + linters_by_ft = { + -- Builtin: https://github.com/mfussenegger/nvim-lint/tree/master/lua/lint/linters + markdown = { "markdownlint" }, + lua = { "luacheck" }, + typescript = { "biomejs" }, + typescriptreact = { "biomejs" }, + javascript = { "biomejs" }, + javascriptreact = { "biomejs" }, + -- Use the "*" filetype to run linters on all filetypes. + -- ['*'] = { 'global linter' }, + -- Use the "_" filetype to run linters on filetypes that don't have other linters configured. + -- ['_'] = { 'fallback linter' }, + -- ["*"] = { "typos" }, + }, + -- LazyVim extension to easily override linter options + -- or add custom linters. + ---@type table + -- + -- Options: + -- cmd = 'linter_cmd', + -- stdin = true, -- or false if it doesn't support content input via stdin. In that case the filename is automatically added to the arguments. + -- append_fname = true, -- Automatically append the file name to `args` if `stdin = false` (default: true) + -- args = {}, -- list of arguments. Can contain functions with zero arguments that will be evaluated once the linter is used. + -- stream = nil, -- ('stdout' | 'stderr' | 'both') configure the stream to which the linter outputs the linting result. + -- ignore_exitcode = false, -- set this to true if the linter exits with a code != 0 and that's considered normal. + -- env = nil, -- custom environment table to use with the external process. Note that this replaces the *entire* environment, it is not additive. + -- parser = your_parse_function + -- + -- your_parse_function can be a function which takes three arguments: + -- output + -- bufnr + -- linter_cwd + -- The output is the output generated by the linter command. The function must return a list of diagnostics as specified in :help diagnostic-structure. + linters = { + luacheck = { + args = { + "--globals", + "vim", + "--globals", + "NIX", + "--globals", + "U", + "--max_line_length", + "240", + "--max_code_line_length", + "240", + "--max_string_line_length", + "240", + "--max_comment_line_length", + "240", + "--formatter", + "plain", + "--codes", + "--ranges", + "-", + }, + }, + -- -- Example of using selene only when a selene.toml file is present + -- selene = { + -- -- `condition` is another LazyVim extension that allows you to + -- -- dynamically enable/disable linters based on the context. + -- condition = function(ctx) + -- return vim.fs.find({ "selene.toml" }, { path = ctx.filename, upward = true })[1] + -- end, + -- }, + }, + }, + config = function(_, opts) + local M = {} + + local lint = require("lint") + for name, linter in pairs(opts.linters) do + if type(linter) == "table" and type(lint.linters[name]) == "table" then + lint.linters[name] = vim.tbl_deep_extend("force", lint.linters[name], linter) + else + lint.linters[name] = linter + end + end + lint.linters_by_ft = opts.linters_by_ft + + function M.debounce(ms, fn) + local timer = vim.uv.new_timer() + return function(...) + local argv = { ... } + timer:start(ms, 0, function() + timer:stop() + vim.schedule_wrap(fn)(unpack(argv)) + end) + end + end + + function M.lint() + -- Use nvim-lint's logic first: + -- * checks if linters exist for the full filetype first + -- * otherwise will split filetype by "." and add all those linters + -- * this differs from conform.nvim which only uses the first filetype that has a formatter + local names = lint._resolve_linter_by_ft(vim.bo.filetype) + + -- Create a copy of the names table to avoid modifying the original. + names = vim.list_extend({}, names) + + -- Add fallback linters. + if #names == 0 then + vim.list_extend(names, lint.linters_by_ft["_"] or {}) + end + + -- Add global linters. + vim.list_extend(names, lint.linters_by_ft["*"] or {}) + + -- Filter out linters that don't exist or don't match the condition. + local ctx = { filename = vim.api.nvim_buf_get_name(0) } + ctx.dirname = vim.fn.fnamemodify(ctx.filename, ":h") + names = vim.tbl_filter(function(name) + local linter = lint.linters[name] + if not linter then + LazyVim.warn("Linter not found: " .. name, { title = "nvim-lint" }) + end + return linter and not (type(linter) == "table" and linter.condition and not linter.condition(ctx)) + end, names) + + -- Run linters. + if #names > 0 then + lint.try_lint(names) + end + end + + vim.api.nvim_create_autocmd(opts.events, { + group = vim.api.nvim_create_augroup("nvim-lint", { clear = true }), + callback = M.debounce(100, M.lint), + }) + end, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 8c7c1ed..7311fdf 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -81,12 +81,21 @@ return { desc = "Resume last telescope", }, { - "fj", + "f/", function() - require("telescope.builtin").current_buffer_fuzzy_find() + require("telescope.builtin").current_buffer_fuzzy_find( + require("telescope.themes").get_dropdown({ winblend = 10, previewer = false }) + ) end, desc = "Fuzzy find/search in current buffer fuzzy.", }, + { + "fh", + function() + require("telescope.builtin").help_tags() + end, + desc = "Find help", + }, { "ff", function() @@ -133,21 +142,21 @@ return { function() require("telescope.builtin").keymaps() end, - desc = "Find Commands", + desc = "Find Keymap", }, { "fb", function() require("telescope.builtin").buffers() end, - desc = "Find Commands", + desc = "Find Buffer", }, { "lfr", function() require("telescope.builtin").lsp_references() end, - desc = "Find References", + desc = "Find LSP References", mode = { "n", "v", "x" }, }, }, diff --git a/lua/tools/quick-fix.lua b/lua/tools/quick-fix.lua index c312e74..cd00bb0 100644 --- a/lua/tools/quick-fix.lua +++ b/lua/tools/quick-fix.lua @@ -14,8 +14,9 @@ vim.api.nvim_create_user_command("RemoveQFItem", RemoveQFItem, {}) -- Auto command to map 'dd' in quickfix window vim.api.nvim_create_autocmd("FileType", { + group = vim.api.nvim_create_augroup("myconfig-quick-fix-group", { clear = true }), pattern = "qf", - callback = function() - vim.keymap.set("n", "dd", RemoveQFItem, { buffer = true, silent = true }) + callback = function(event) + vim.keymap.set("n", "dd", RemoveQFItem, { buffer = event.buffer, silent = true }) end, }) diff --git a/lua/util.lua b/lua/util.lua index 1e481fc..8149e60 100644 --- a/lua/util.lua +++ b/lua/util.lua @@ -48,7 +48,7 @@ function M.keymap(keymap) local lhs = keymap[1] local rhs = keymap[2] local mode = keymap["mode"] or "n" - local opts = {} + local opts = { silent = true } for key, value in pairs(keymap) do if type(key) ~= "number" and key ~= "mode" then opts[key] = value