diff --git a/README.md b/README.md index 0031d1a..22e5b6b 100644 --- a/README.md +++ b/README.md @@ -157,5 +157,5 @@ This is how it looks like: - ollama integration - Solution to run file_browser when doing a vertical/horizontal split? -- https://github.com/folke/trouble.nvim +- - Implement linting, see diff --git a/lazy-lock.json b/lazy-lock.json index eb4fd3b..55fd9cb 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -21,6 +21,8 @@ "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, "telescope.nvim": { "branch": "master", "commit": "7011eaae0ac1afe036e30c95cf80200b8dc3f21a" }, "tokyonight.nvim": { "branch": "main", "commit": "f247ee700b569ed43f39320413a13ba9b0aef0db" }, + "twilight.nvim": { "branch": "main", "commit": "8b7b50c0cb2dc781b2f4262a5ddd57571556d1e4" }, "vim-illuminate": { "branch": "master", "commit": "3bd2ab64b5d63b29e05691e624927e5ebbf0fb86" }, - "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" } + "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }, + "zen-mode.nvim": { "branch": "main", "commit": "50e2e2a36cc97847d9ab3b1a3555ba2ef6839b50" } } \ No newline at end of file diff --git a/lua/weeheavy/plugins/lsp/lsp-zero.lua b/lua/weeheavy/plugins/lsp/lsp-zero.lua index 16b7bdf..d35dc1b 100644 --- a/lua/weeheavy/plugins/lsp/lsp-zero.lua +++ b/lua/weeheavy/plugins/lsp/lsp-zero.lua @@ -1,93 +1,98 @@ return { - { - 'VonHeikemen/lsp-zero.nvim', - branch = 'v3.x', - lazy = true, - config = false, - init = function() - -- Disable automatic setup, we are doing it manually - vim.g.lsp_zero_extend_cmp = 0 - vim.g.lsp_zero_extend_lspconfig = 0 - end, - }, - { - 'williamboman/mason.nvim', - lazy = false, - config = true, - }, - { - 'hrsh7th/nvim-cmp', - event = 'InsertEnter', - dependencies = { - {'L3MON4D3/LuaSnip'}, - }, - config = function() - -- Here is where you configure the autocompletion settings. - local lsp_zero = require('lsp-zero') - lsp_zero.extend_cmp() + { + "VonHeikemen/lsp-zero.nvim", + branch = "v3.x", + lazy = true, + config = false, + init = function() + -- Disable automatic setup, we are doing it manually + vim.g.lsp_zero_extend_cmp = 0 + vim.g.lsp_zero_extend_lspconfig = 0 + end, + }, + { + "williamboman/mason.nvim", + lazy = false, + config = true, + }, + { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + { "L3MON4D3/LuaSnip" }, + }, + config = function() + -- Here is where you configure the autocompletion settings. + local lsp_zero = require("lsp-zero") + lsp_zero.extend_cmp() - local cmp = require('cmp') - local cmp_action = lsp_zero.cmp_action() - local cmp_select = { behavior = cmp.SelectBehavior.Select } + local cmp = require("cmp") + local cmp_action = lsp_zero.cmp_action() + local cmp_select = { behavior = cmp.SelectBehavior.Select } - cmp.setup({ - formatting = lsp_zero.cmp_format(), - mapping = cmp.mapping.preset.insert({ - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.confirm({select = true}), -- accept LSP autocompletion - [''] = cmp.mapping.select_prev_item(cmp_select), - [''] = cmp.mapping.select_next_item(cmp_select), - [''] = cmp_action.luasnip_jump_forward(), - [''] = cmp_action.luasnip_jump_backward(), - }) - }) - end - }, + cmp.setup({ + formatting = lsp_zero.cmp_format(), + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.confirm({ select = true }), -- accept LSP autocompletion + [""] = cmp.mapping.select_prev_item(cmp_select), + [""] = cmp.mapping.select_next_item(cmp_select), + [""] = cmp_action.luasnip_jump_forward(), + [""] = cmp_action.luasnip_jump_backward(), + }), + }) + end, + }, - -- LSP - { - 'neovim/nvim-lspconfig', - cmd = {'LspInfo', 'LspInstall', 'LspStart'}, - event = {'BufReadPre', 'BufNewFile'}, - dependencies = { - {'hrsh7th/cmp-nvim-lsp'}, - {'williamboman/mason-lspconfig.nvim'}, - }, - config = function() - -- This is where all the LSP shenanigans will live - local lsp_zero = require('lsp-zero') - lsp_zero.extend_lspconfig() + -- LSP + { + "neovim/nvim-lspconfig", + cmd = { "LspInfo", "LspInstall", "LspStart" }, + event = { "BufReadPre", "BufNewFile" }, + dependencies = { + { "hrsh7th/cmp-nvim-lsp" }, + { "williamboman/mason-lspconfig.nvim" }, + }, + config = function() + -- This is where all the LSP shenanigans will live + local lsp_zero = require("lsp-zero") + lsp_zero.extend_lspconfig() - -- Keybindings only active when a LS is active for the curr. file - lsp_zero.on_attach(function(client, bufnr) - -- see :help lsp-zero-keybindings - -- to learn the available actions - lsp_zero.default_keymaps({buffer = bufnr}) - end) + -- Keybindings only active when a LS is active for the curr. file + lsp_zero.on_attach(function(client, bufnr) + -- see :help lsp-zero-keybindings + -- to learn the available actions + lsp_zero.default_keymaps({ buffer = bufnr }) + end) - require('mason').setup({ - ui = { - icons = { - package_installed = "✓", - package_pending = "➜", - package_uninstalled = "✗", - }, - }, - }) + require("mason").setup({ + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗", + }, + }, + }) - require('mason-lspconfig').setup({ - ensure_installed = {}, - handlers = { - lsp_zero.default_setup, - lua_ls = function() - -- (Optional) Configure lua language server for neovim - local lua_opts = lsp_zero.nvim_lua_ls() - require('lspconfig').lua_ls.setup(lua_opts) - end, - } - }) - end - } + require("mason-lspconfig").setup({ + ensure_installed = {}, + handlers = { + -- names must align with Mason names + lsp_zero.default_setup, + lua_ls = function() + local lua_opts = lsp_zero.nvim_lua_ls() + require("lspconfig").lua_ls.setup(lua_opts) + end, + --ansiblels = function() + -- require("lspconfig").ansiblels.setup({ + -- filetypes = "yaml", + -- }) + --end, + }, + }) + end, + }, } diff --git a/lua/weeheavy/plugins/telescope.lua b/lua/weeheavy/plugins/telescope.lua index 17de6d0..ebe87e7 100644 --- a/lua/weeheavy/plugins/telescope.lua +++ b/lua/weeheavy/plugins/telescope.lua @@ -1,50 +1,49 @@ return { - "nvim-telescope/telescope.nvim", - tag = "0.1.4", - dependencies = { - "nvim-lua/plenary.nvim", - }, - --config = function(lazy, opts) - config = function() - local telescope = require('telescope') - telescope.load_extension('fzf') - telescope.load_extension('file_browser') - telescope.setup({ - defaults = { - sorting_strategy = "ascending", - wrap_result = true, - layout_strategy = "horizontal", - layout_config = { - horizontal = { - prompt_position = "top", - preview_width = 0.4, - width = 0.75, - height = 0.75, - preview_cutoff = 90, - } - } - }, - pickers = { - find_files = { - hidden = true - }, - live_grep = { - additional_args = function() - return { '--hidden', '--glob', '!**/.git/*' } - end - }, - grep_string = { - additional_args = function() - return { '--hidden', '--glob', '!**/.git/*' } - end - }, - -- note: remove the 'builtin.' prefix. - ["lsp_references"] = { wrap_results = true, }, - ["lsp_definitions"] = { wrap_results = true, }, - ["diagnostics"] = { wrap_results = true, }, - ["find_files"] = { wrap_results = true, }, - ["buffers"] = { sort_mru = true, ignore_current_buffer = true }, - } - }) - end + "nvim-telescope/telescope.nvim", + tag = "0.1.4", + dependencies = { + "nvim-lua/plenary.nvim", + }, + --config = function(lazy, opts) + config = function() + local telescope = require("telescope") + telescope.load_extension("fzf") + telescope.load_extension("file_browser") + telescope.setup({ + defaults = { + sorting_strategy = "ascending", + wrap_result = true, + layout_strategy = "horizontal", + layout_config = { + horizontal = { + prompt_position = "top", + preview_width = 0.4, + width = 0.75, + height = 0.75, + preview_cutoff = 90, + }, + }, + }, + pickers = { + find_files = { + hidden = true, + wrap_results = false, -- this is not about the preview + }, + live_grep = { + additional_args = function() + return { "--hidden", "--glob", "!**/.git/*" } + end, + }, + grep_string = { + additional_args = function() + return { "--hidden", "--glob", "!**/.git/*" } + end, + }, + ["lsp_references"] = { wrap_results = true }, + ["lsp_definitions"] = { wrap_results = true }, + ["diagnostics"] = { wrap_results = true }, + ["buffers"] = { sort_mru = true, ignore_current_buffer = false }, + }, + }) + end, } diff --git a/lua/weeheavy/plugins/treesitter.lua b/lua/weeheavy/plugins/treesitter.lua index 34f27c9..e5a05c1 100644 --- a/lua/weeheavy/plugins/treesitter.lua +++ b/lua/weeheavy/plugins/treesitter.lua @@ -1,48 +1,56 @@ -- Treesitter return { - "nvim-treesitter/nvim-treesitter", - build = ":TSUpdate", - event = { "BufReadPre", "BufNewFile" }, - dependencies = { - "nvim-treesitter/nvim-treesitter-textobjects", - }, - config = function() - local treesitter = require("nvim-treesitter.configs") + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { + "nvim-treesitter/nvim-treesitter-textobjects", + }, + config = function() + local treesitter = require("nvim-treesitter.configs") - treesitter.setup({ - highlight = { enable = true, }, - indent = { enable = true }, - auto_install = false, - -- language list: https://github.com/nvim-treesitter/nvim-treesitter#supported-languages - ensure_installed = { - "lua", - "comment", - "vim", - "vimdoc", - "bash", - "diff", - "gitignore", - "markdown", - "markdown_inline", - "elixir", - "eex", - "heex", - "yaml", - "html", - "css", - "dockerfile", - "query", - "hcl", - }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = "", - node_incremental = "", - scope_incremental = false, - node_decremental = "", - }, - }, - }) - end + treesitter.setup({ + highlight = { enable = true }, + indent = { enable = true }, + auto_install = false, + -- language list: https://github.com/nvim-treesitter/nvim-treesitter#supported-languages + ensure_installed = { + "lua", + "comment", -- used for TODO/FIXME/NOTE etc + "vim", + "vimdoc", + "bash", + "diff", + "gitignore", + "markdown", + "markdown_inline", + "elixir", + "eex", + "heex", + "yaml", + "html", + "javascript", + "css", + "dockerfile", + "query", + "hcl", + "bicep", + "csv", + "properties", + "ini", + "python", + "regex", + "json", + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", + node_incremental = "", + scope_incremental = false, + node_decremental = "", + }, + }, + }) + end, } diff --git a/lua/weeheavy/plugins/zenmode.lua b/lua/weeheavy/plugins/zenmode.lua new file mode 100644 index 0000000..8d82ad8 --- /dev/null +++ b/lua/weeheavy/plugins/zenmode.lua @@ -0,0 +1,13 @@ +-- Distraction-free coding when you need it +-- https://github.com/folke/zen-mode.nvim +return { + "folke/zen-mode.nvim", + dependencies = { + "folke/twilight.nvim", + opts = { + context = 2, + }, + }, + event = { "BufReadPre", "BufNewFile" }, + opts = {}, +} diff --git a/lua/weeheavy/prefs.lua b/lua/weeheavy/prefs.lua index 32ec12c..2071219 100644 --- a/lua/weeheavy/prefs.lua +++ b/lua/weeheavy/prefs.lua @@ -9,7 +9,7 @@ vim.opt.number = true vim.opt.relativenumber = true -- Separate sign colum (extra column for Git/LSP) -vim.wo.signcolumn = 'yes' +vim.wo.signcolumn = "yes" vim.opt.tabstop = 4 vim.opt.softtabstop = 4 @@ -17,7 +17,7 @@ vim.opt.shiftwidth = 4 vim.opt.expandtab = true -- indent using spaces instead of -- highlight columns -vim.opt.colorcolumn = '80,120' +vim.opt.colorcolumn = "80,120" -- Sync clipboard between OS and Neovim. -- Remove this option if you want your OS clipboard to remain independent. @@ -40,13 +40,13 @@ vim.opt.scrolloff = 5 vim.opt.wrap = false vim.opt.termguicolors = true -vim.opt.background = 'dark' -- light, dark +vim.opt.background = "dark" -- light, dark -- Themes: duskfox, tokyonight-night, tokyonight-storm, tokyonight-day, tokyonight-moon -vim.cmd.colorscheme 'tokyonight-storm' +vim.cmd.colorscheme("tokyonight-storm") -- Decrease update time vim.opt.updatetime = 250 vim.opt.timeoutlen = 300 -- Set completeopt to have a better completion experience -vim.opt.completeopt = 'menuone,noselect' +vim.opt.completeopt = "menuone,noselect" diff --git a/lua/weeheavy/remap.lua b/lua/weeheavy/remap.lua index fc20db9..8454e59 100644 --- a/lua/weeheavy/remap.lua +++ b/lua/weeheavy/remap.lua @@ -18,13 +18,14 @@ vim.keymap.set( ":Telescope find_files hidden=true no_ignore=false ", { noremap = true, desc = "File search" } ) -vim.keymap.set("n", "fg", ":Telescope live_grep", { noremap = true, desc = "Live grep through all files" }) +--vim.keymap.set("n", "fg", ":Telescope live_grep", { noremap = true, desc = "Live grep through all files" }) vim.keymap.set( "n", - "", - ":Telescope buffers preview=false", - { noremap = true, desc = "Show open buffers" } + "fg", + ":Telescope grep_string", + { noremap = true, desc = "Search text under cursor in cwd/grep search string" } ) +vim.keymap.set("n", "", ":Telescope buffers", { noremap = true, desc = "Show open buffers" }) vim.keymap.set("n", "gst", ":Telescope git_status", { noremap = true, desc = "Git status" }) vim.keymap.set( "n", @@ -68,3 +69,5 @@ vim.keymap.set({ "n", "v" }, "o", function() timeout_ms = 500, }) end, { desc = "Format file or range (in visual mode)" }) + +vim.keymap.set("n", "z", ":ZenMode") -- toggle zen-mode.nvim