From 1ea4e128bb8519bc6d3b917b21abadd8905a49b2 Mon Sep 17 00:00:00 2001 From: Sarjyant Date: Thu, 26 Sep 2024 10:00:26 +0545 Subject: [PATCH] cord, nvim-lint --- init.lua | 4 +- lua/kickstart/plugins/cord.lua | 72 +++++++++++++++++++++++++++++ lua/kickstart/plugins/nvim-cmp.lua | 48 ++++++++++++------- lua/kickstart/plugins/nvim-lint.lua | 55 ++++++++++++++++++++++ 4 files changed, 162 insertions(+), 17 deletions(-) create mode 100644 lua/kickstart/plugins/cord.lua create mode 100644 lua/kickstart/plugins/nvim-lint.lua diff --git a/init.lua b/init.lua index 0ab991fd..15f4f6ae 100644 --- a/init.lua +++ b/init.lua @@ -455,12 +455,14 @@ require('lazy').setup({ require 'kickstart.plugins.dap', require 'kickstart.plugins.debug', require 'kickstart.plugins.fzf-telescope', - require 'kickstart.plugins.indent_line', require 'kickstart.plugins.lsp-config', require 'kickstart.plugins.mini', require 'kickstart.plugins.nvim-cmp', require 'kickstart.plugins.treesitter', require 'kickstart.plugins.vim-fugitive', + require 'kickstart.plugins.nvim-lint', + require 'kickstart.plugins.cord', + -- require 'kickstart.plugins.indent_line', -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`. -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` diff --git a/lua/kickstart/plugins/cord.lua b/lua/kickstart/plugins/cord.lua new file mode 100644 index 00000000..fed50f0b --- /dev/null +++ b/lua/kickstart/plugins/cord.lua @@ -0,0 +1,72 @@ +return { + 'vyfor/cord.nvim', + build = './build || .\\build', + event = 'VeryLazy', + -- opts = {}, -- calls require('cord').setup() + config = function() + require('cord').setup { + usercmds = true, -- Enable user commands + log_level = 'error', -- One of 'trace', 'debug', 'info', 'warn', 'error', 'off' + timer = { + interval = 1500, -- Interval between presence updates in milliseconds (min 500) + reset_on_idle = false, -- Reset start timestamp on idle + reset_on_change = false, -- Reset start timestamp on presence change + }, + editor = { + image = nil, -- Image ID or URL in case a custom client id is provided + client = 'neovim', -- vim, neovim, lunarvim, nvchad, astronvim or your application's client id + tooltip = 'The Superior Text Editor', -- Text to display when hovering over the editor's image + }, + display = { + show_time = true, -- Display start timestamp + show_repository = false, -- Display 'View repository' button linked to repository url, if any + show_cursor_position = false, -- Display line and column number of cursor's position + swap_fields = false, -- If enabled, workspace is displayed first + swap_icons = false, -- If enabled, editor is displayed on the main image + workspace_blacklist = {}, -- List of workspace names that will hide rich presence + }, + lsp = { + show_problem_count = false, -- Display number of diagnostics problems + severity = 1, -- 1 = Error, 2 = Warning, 3 = Info, 4 = Hint + scope = 'workspace', -- buffer or workspace + }, + idle = { + enable = true, -- Enable idle status + show_status = true, -- Display idle status, disable to hide the rich presence on idle + timeout = 300000, -- Timeout in milliseconds after which the idle status is set, 0 to display immediately + disable_on_focus = false, -- Do not display idle status when neovim is focused + text = 'Idle', -- Text to display when idle + tooltip = '💤', -- Text to display when hovering over the idle image + }, + text = { + viewing = 'Viewing {}', -- Text to display when viewing a readonly file + editing = 'Editing {}', -- Text to display when editing a file + -- file_browser = 'Browsing files in {}', -- Text to display when browsing files (Empty string to disable) + plugin_manager = 'Managing plugins in {}', -- Text to display when managing plugins (Empty string to disable) + lsp_manager = 'Configuring LSP in {}', -- Text to display when managing LSP servers (Empty string to disable) + vcs = 'Committing changes in {}', -- Text to display when using Git or Git-related plugin (Empty string to disable) + workspace = '', -- Text to display when in a workspace (In {} | Empty string to disable) + }, + buttons = { + { + label = 'View Repository', -- Text displayed on the button + url = 'git', -- URL where the button leads to ('git' = automatically fetch Git repository URL) + }, + -- { + -- label = 'View Plugin', + -- url = 'https://github.com/vyfor/cord.nvim', + -- } + }, + assets = nil, -- Custom file icons, see the wiki* + -- assets = { + -- lazy = { -- Vim filetype or file name or file extension = table or string + -- name = 'Lazy', -- Optional override for the icon name, redundant for language types + -- icon = 'https://example.com/lazy.png', -- Rich Presence asset name or URL + -- tooltip = 'lazy.nvim', -- Text to display when hovering over the icon + -- type = 2, -- 0 = language, 1 = file browser, 2 = plugin manager, 3 = lsp manager, 4 = vcs; defaults to language + -- }, + -- ['Cargo.toml'] = 'crates', + -- }, + } + end, +} diff --git a/lua/kickstart/plugins/nvim-cmp.lua b/lua/kickstart/plugins/nvim-cmp.lua index 40aa016a..9d245b17 100644 --- a/lua/kickstart/plugins/nvim-cmp.lua +++ b/lua/kickstart/plugins/nvim-cmp.lua @@ -7,14 +7,25 @@ return { { 'L3MON4D3/LuaSnip', build = (function() - -- Build Step is needed for regex support in snippets - -- This step is not supported in many windows environments - -- Remove the below condition to re-enable on windows + -- Build Step is needed for regex support in snippets. + -- This step is not supported in many windows environments. + -- Remove the below condition to re-enable on windows. if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then return end return 'make install_jsregexp' end)(), + dependencies = { + -- `friendly-snippets` contains a variety of premade snippets. + -- See the README about individual language/framework/plugin snippets: + -- https://github.com/rafamadriz/friendly-snippets + { + 'rafamadriz/friendly-snippets', + config = function() + require('luasnip.loaders.from_vscode').lazy_load() + end, + }, + }, }, 'saadparwaiz1/cmp_luasnip', @@ -23,18 +34,11 @@ return { -- into multiple repos for maintenance purposes. 'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-path', - - -- If you want to add a bunch of pre-configured snippets, - -- you can use this plugin to help you. It even has snippets - -- for various frameworks/libraries/etc. but you will have to - -- set up the ones that are useful for you. - 'rafamadriz/friendly-snippets', }, config = function() -- See `:help cmp` local cmp = require 'cmp' local luasnip = require 'luasnip' - require('luasnip.loaders.from_vscode').lazy_load() luasnip.config.setup {} cmp.setup { @@ -55,11 +59,21 @@ return { -- Select the [p]revious item [''] = cmp.mapping.select_prev_item(), + -- Scroll the documentation window [b]ack / [f]orward + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + -- Accept ([y]es) the completion. -- This will auto-import if your LSP supports it. -- This will expand snippets if the LSP sent a snippet. [''] = cmp.mapping.confirm { select = true }, + -- If you prefer more traditional completion keymaps, + -- you can uncomment the following lines + --[''] = cmp.mapping.confirm { select = true }, + --[''] = cmp.mapping.select_next_item(), + --[''] = cmp.mapping.select_prev_item(), + -- Manually trigger a completion from nvim-cmp. -- Generally you don't need this, because nvim-cmp will display -- completions whenever it has completion options available. @@ -83,19 +97,21 @@ return { luasnip.jump(-1) end end, { 'i', 's' }), + + -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: + -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps }, sources = { + { + name = 'lazydev', + -- set group index to 0 to skip loading LuaLS completions as lazydev recommends it + group_index = 0, + }, { name = 'nvim_lsp' }, { name = 'luasnip' }, { name = 'path' }, }, } - cmp.setup.filetype({ 'sql' }, { - sources = { - { name = 'vim-dadbod-completion' }, - { name = 'buffer' }, - }, - }) end, }, } diff --git a/lua/kickstart/plugins/nvim-lint.lua b/lua/kickstart/plugins/nvim-lint.lua new file mode 100644 index 00000000..ca9bc237 --- /dev/null +++ b/lua/kickstart/plugins/nvim-lint.lua @@ -0,0 +1,55 @@ +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() + lint.try_lint() + end, + }) + end, + }, +}