From 8a37b7072e045925b359be4f10fb54b6bc598d8d Mon Sep 17 00:00:00 2001 From: adollar <71227493+abp1994@users.noreply.github.com> Date: Thu, 26 Jun 2025 01:50:02 +0100 Subject: [PATCH] started to add go functionality --- init.lua | 215 +++++++++++-------------------------- lua/plugins/conform.lua | 39 +++++++ lua/plugins/lsp.lua | 4 +- lua/plugins/telescope.nvim | 0 4 files changed, 104 insertions(+), 154 deletions(-) create mode 100644 lua/plugins/conform.lua create mode 100644 lua/plugins/telescope.nvim diff --git a/init.lua b/init.lua index 40ed721a..63835610 100644 --- a/init.lua +++ b/init.lua @@ -6,7 +6,6 @@ require 'core.snippets' vim.g.have_nerd_font = true -- [[ Install `lazy.nvim` plugin manager ]] --- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' if not (vim.uv or vim.loop).fs_stat(lazypath) then local lazyrepo = 'https://github.com/folke/lazy.nvim.git' @@ -20,55 +19,8 @@ end local rtp = vim.opt.rtp rtp:prepend(lazypath) --- [[ Configure and install plugins ]] --- --- To check the current status of your plugins, run --- :Lazy --- --- You can press `?` in this menu for help. Use `:q` to close the window --- --- To update plugins you can run --- :Lazy update --- --- NOTE: Here is where you install your plugins. require('lazy').setup({ - -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). 'NMAC427/guess-indent.nvim', -- Detect tabstop and shiftwidth automatically - - -- NOTE: Plugins can also be added by using a table, - -- with the first argument being the link and the following - -- keys can be used to configure plugin behavior/loading/etc. - -- - -- Use `opts = {}` to automatically pass options to a plugin's `setup()` function, forcing the plugin to be loaded. - -- - - -- Alternatively, use `config = function() ... end` for full control over the configuration. - -- If you prefer to call `setup` explicitly, use: - -- { - -- 'lewis6991/gitsigns.nvim', - -- config = function() - -- require('gitsigns').setup({ - -- -- Your gitsigns configuration here - -- }) - -- end, - -- } - -- - -- Here is a more advanced example where we pass configuration - -- options to `gitsigns.nvim`. - -- - -- See `:help gitsigns` to understand what the configuration keys do - { -- Adds git related signs to the gutter, as well as utilities for managing changes - 'lewis6991/gitsigns.nvim', - opts = { - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - }, - }, - }, require 'plugins.neo-tree', require 'plugins.autopairs', require 'plugins.gitsigns', @@ -79,73 +31,72 @@ require('lazy').setup({ require 'plugins.fugitive', require 'plugins.rhubarb', require 'plugins.lsp', + require 'plugins.conform', + -- NOTE: Plugins can also be configured to run Lua code when they are loaded. + -- + -- This is often very useful to both group configuration, as well as handle + -- lazy loading plugins that don't need to be loaded immediately at startup. + -- + -- For example, in the following configuration, we use: + -- event = 'VimEnter' + -- + -- which loads which-key before all the UI elements are loaded. Events can be + -- normal autocommands events (`:help autocmd-events`). + -- + -- Then, because we use the `opts` key (recommended), the configuration runs + -- after the plugin has been loaded as `requpre(MODULE).setup(opts)`. + { -- Useful plugin to show you pending keybinds. + 'folke/which-key.nvim', + event = 'VimEnter', -- Sets the loading event to 'VimEnter' + opts = { + -- delay between pressing a key and opening which-key (milliseconds) + -- this setting is independent of vim.o.timeoutlen + delay = 0, + icons = { + -- set icon mappings to true if you have a Nerd Font + mappings = vim.g.have_nerd_font, + -- If you are using a Nerd Font: set icons.keys to an empty table which will use the + -- default which-key.nvim defined Nerd Font icons, otherwise define a string table + keys = vim.g.have_nerd_font and {} or { + Up = ' ', + Down = ' ', + Left = ' ', + Right = ' ', + C = ' ', + M = ' ', + D = ' ', + S = ' ', + CR = ' ', + Esc = ' ', + ScrollWheelDown = ' ', + ScrollWheelUp = ' ', + NL = ' ', + BS = ' ', + Space = ' ', + Tab = ' ', + F1 = '', + F2 = '', + F3 = '', + F4 = '', + F5 = '', + F6 = '', + F7 = '', + F8 = '', + F9 = '', + F10 = '', + F11 = '', + F12 = '', + }, + }, - -- NOTE: Plugins can also be configured to run Lua code when they are loaded. - -- - -- This is often very useful to both group configuration, as well as handle - -- lazy loading plugins that don't need to be loaded immediately at startup. - -- - -- For example, in the following configuration, we use: - -- event = 'VimEnter' - -- - -- which loads which-key before all the UI elements are loaded. Events can be - -- normal autocommands events (`:help autocmd-events`). - -- - -- Then, because we use the `opts` key (recommended), the configuration runs - -- after the plugin has been loaded as `requpre(MODULE).setup(opts)`. - - { -- Useful plugin to show you pending keybinds. - 'folke/which-key.nvim', - event = 'VimEnter', -- Sets the loading event to 'VimEnter' - opts = { - -- delay between pressing a key and opening which-key (milliseconds) - -- this setting is independent of vim.o.timeoutlen - delay = 0, - icons = { - -- set icon mappings to true if you have a Nerd Font - mappings = vim.g.have_nerd_font, - -- If you are using a Nerd Font: set icons.keys to an empty table which will use the - -- default which-key.nvim defined Nerd Font icons, otherwise define a string table - keys = vim.g.have_nerd_font and {} or { - Up = ' ', - Down = ' ', - Left = ' ', - Right = ' ', - C = ' ', - M = ' ', - D = ' ', - S = ' ', - CR = ' ', - Esc = ' ', - ScrollWheelDown = ' ', - ScrollWheelUp = ' ', - NL = ' ', - BS = ' ', - Space = ' ', - Tab = ' ', - F1 = '', - F2 = '', - F3 = '', - F4 = '', - F5 = '', - F6 = '', - F7 = '', - F8 = '', - F9 = '', - F10 = '', - F11 = '', - F12 = '', + -- Document existing key chains + spec = { + { 's', group = '[S]earch' }, + { 't', group = '[T]oggle' }, + { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, }, }, - - -- Document existing key chains - spec = { - { 's', group = '[S]earch' }, - { 't', group = '[T]oggle' }, - { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, - }, }, - }, -- NOTE: Plugins can specify dependencies. -- @@ -258,48 +209,6 @@ require('lazy').setup({ end, }, - { -- Autoformat - 'stevearc/conform.nvim', - event = { 'BufWritePre' }, - cmd = { 'ConformInfo' }, - keys = { - { - 'f', - function() - require('conform').format { async = true, lsp_format = 'fallback' } - end, - mode = '', - desc = '[F]ormat buffer', - }, - }, - opts = { - notify_on_error = false, - format_on_save = function(bufnr) - -- Disable "format_on_save lsp_fallback" for languages that don't - -- have a well standardized coding style. You can add additional - -- languages here or re-enable it for the disabled ones. - local disable_filetypes = { c = true, cpp = true } - if disable_filetypes[vim.bo[bufnr].filetype] then - return nil - else - return { - timeout_ms = 500, - lsp_format = 'fallback', - } - end - end, - formatters_by_ft = { - lua = { 'stylua' }, - python = { 'ruff_fix', 'ruff_format', 'ruff_organize_imports' }, - -- Conform can also run multiple formatters sequentially - -- python = { "isort", "black" }, - -- - -- You can use 'stop_after_first' to run the first available formatter from the list - -- javascript = { "prettierd", "prettier", stop_after_first = true }, - }, - }, - }, - { -- Autocompletion 'saghen/blink.cmp', event = 'VimEnter', diff --git a/lua/plugins/conform.lua b/lua/plugins/conform.lua new file mode 100644 index 00000000..6c573f3d --- /dev/null +++ b/lua/plugins/conform.lua @@ -0,0 +1,39 @@ +return { -- Autoformat + 'stevearc/conform.nvim', + event = { 'BufWritePre' }, + cmd = { 'ConformInfo' }, + keys = { + { + 'f', + function() + require('conform').format { async = true, lsp_format = 'fallback' } + end, + mode = '', + desc = '[F]ormat buffer', + }, + }, + opts = { + notify_on_error = false, + format_on_save = function(bufnr) + -- Disable "format_on_save lsp_fallback" for languages that don't + -- have a well standardized coding style. You can add additional + -- languages here or re-enable it for the disabled ones. + local disable_filetypes = { c = true, cpp = true } + if disable_filetypes[vim.bo[bufnr].filetype] then + return nil + else + return { + timeout_ms = 500, + lsp_format = 'fallback', + } + end + end, + formatters_by_ft = { + lua = { 'stylua' }, + python = { 'ruff_fix', 'ruff_format', 'ruff_organize_imports' }, + -- You can use 'stop_after_first' to run the first available formatter from the list + javascript = { 'prettierd' }, + go = { 'goimports' }, + }, + }, +} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index e389a75a..e9b84b11 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -210,7 +210,7 @@ return { -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { -- clangd = {}, - -- gopls = {}, + gopls = {}, -- pyright = {}, ruff = {}, -- rust_analyzer = {}, @@ -254,6 +254,8 @@ return { local ensure_installed = vim.tbl_keys(servers or {}) vim.list_extend(ensure_installed, { 'stylua', -- Used to format Lua code + 'goimports', + 'prettierd', }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } diff --git a/lua/plugins/telescope.nvim b/lua/plugins/telescope.nvim new file mode 100644 index 00000000..e69de29b