add zen plugin, remap cleanup/combination, add more languages to treesitter

This commit is contained in:
Oliver Ladner 2023-12-05 15:50:20 +01:00
commit cbd4c176ef
8 changed files with 218 additions and 188 deletions

View file

@ -157,5 +157,5 @@ This is how it looks like:
- ollama integration <https://github.com/nomnivore/ollama.nvim> - ollama integration <https://github.com/nomnivore/ollama.nvim>
- Solution to run file_browser when doing a vertical/horizontal split? - Solution to run file_browser when doing a vertical/horizontal split?
- https://github.com/folke/trouble.nvim - <https://github.com/folke/trouble.nvim>
- Implement linting, see <https://www.josean.com/posts/neovim-linting-and-formatting> - Implement linting, see <https://www.josean.com/posts/neovim-linting-and-formatting>

View file

@ -21,6 +21,8 @@
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" },
"telescope.nvim": { "branch": "master", "commit": "7011eaae0ac1afe036e30c95cf80200b8dc3f21a" }, "telescope.nvim": { "branch": "master", "commit": "7011eaae0ac1afe036e30c95cf80200b8dc3f21a" },
"tokyonight.nvim": { "branch": "main", "commit": "f247ee700b569ed43f39320413a13ba9b0aef0db" }, "tokyonight.nvim": { "branch": "main", "commit": "f247ee700b569ed43f39320413a13ba9b0aef0db" },
"twilight.nvim": { "branch": "main", "commit": "8b7b50c0cb2dc781b2f4262a5ddd57571556d1e4" },
"vim-illuminate": { "branch": "master", "commit": "3bd2ab64b5d63b29e05691e624927e5ebbf0fb86" }, "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" }
} }

View file

@ -1,7 +1,7 @@
return { return {
{ {
'VonHeikemen/lsp-zero.nvim', "VonHeikemen/lsp-zero.nvim",
branch = 'v3.x', branch = "v3.x",
lazy = true, lazy = true,
config = false, config = false,
init = function() init = function()
@ -11,53 +11,53 @@ return {
end, end,
}, },
{ {
'williamboman/mason.nvim', "williamboman/mason.nvim",
lazy = false, lazy = false,
config = true, config = true,
}, },
{ {
'hrsh7th/nvim-cmp', "hrsh7th/nvim-cmp",
event = 'InsertEnter', event = "InsertEnter",
dependencies = { dependencies = {
{'L3MON4D3/LuaSnip'}, { "L3MON4D3/LuaSnip" },
}, },
config = function() config = function()
-- Here is where you configure the autocompletion settings. -- Here is where you configure the autocompletion settings.
local lsp_zero = require('lsp-zero') local lsp_zero = require("lsp-zero")
lsp_zero.extend_cmp() lsp_zero.extend_cmp()
local cmp = require('cmp') local cmp = require("cmp")
local cmp_action = lsp_zero.cmp_action() local cmp_action = lsp_zero.cmp_action()
local cmp_select = { behavior = cmp.SelectBehavior.Select } local cmp_select = { behavior = cmp.SelectBehavior.Select }
cmp.setup({ cmp.setup({
formatting = lsp_zero.cmp_format(), formatting = lsp_zero.cmp_format(),
mapping = cmp.mapping.preset.insert({ mapping = cmp.mapping.preset.insert({
['<C-Space>'] = cmp.mapping.complete(), ["<C-Space>"] = cmp.mapping.complete(),
['<C-u>'] = cmp.mapping.scroll_docs(-4), ["<C-u>"] = cmp.mapping.scroll_docs(-4),
['<C-d>'] = cmp.mapping.scroll_docs(4), ["<C-d>"] = cmp.mapping.scroll_docs(4),
['<C-l>'] = cmp.mapping.confirm({select = true}), -- accept LSP autocompletion ["<C-l>"] = cmp.mapping.confirm({ select = true }), -- accept LSP autocompletion
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select), ["<C-p>"] = cmp.mapping.select_prev_item(cmp_select),
['<C-n>'] = cmp.mapping.select_next_item(cmp_select), ["<C-n>"] = cmp.mapping.select_next_item(cmp_select),
['<C-f>'] = cmp_action.luasnip_jump_forward(), ["<C-f>"] = cmp_action.luasnip_jump_forward(),
['<C-b>'] = cmp_action.luasnip_jump_backward(), ["<C-b>"] = cmp_action.luasnip_jump_backward(),
}),
}) })
}) end,
end
}, },
-- LSP -- LSP
{ {
'neovim/nvim-lspconfig', "neovim/nvim-lspconfig",
cmd = {'LspInfo', 'LspInstall', 'LspStart'}, cmd = { "LspInfo", "LspInstall", "LspStart" },
event = {'BufReadPre', 'BufNewFile'}, event = { "BufReadPre", "BufNewFile" },
dependencies = { dependencies = {
{'hrsh7th/cmp-nvim-lsp'}, { "hrsh7th/cmp-nvim-lsp" },
{'williamboman/mason-lspconfig.nvim'}, { "williamboman/mason-lspconfig.nvim" },
}, },
config = function() config = function()
-- This is where all the LSP shenanigans will live -- This is where all the LSP shenanigans will live
local lsp_zero = require('lsp-zero') local lsp_zero = require("lsp-zero")
lsp_zero.extend_lspconfig() lsp_zero.extend_lspconfig()
-- Keybindings only active when a LS is active for the curr. file -- Keybindings only active when a LS is active for the curr. file
@ -67,7 +67,7 @@ return {
lsp_zero.default_keymaps({ buffer = bufnr }) lsp_zero.default_keymaps({ buffer = bufnr })
end) end)
require('mason').setup({ require("mason").setup({
ui = { ui = {
icons = { icons = {
package_installed = "", package_installed = "",
@ -77,17 +77,22 @@ return {
}, },
}) })
require('mason-lspconfig').setup({ require("mason-lspconfig").setup({
ensure_installed = {}, ensure_installed = {},
handlers = { handlers = {
-- names must align with Mason names
lsp_zero.default_setup, lsp_zero.default_setup,
lua_ls = function() lua_ls = function()
-- (Optional) Configure lua language server for neovim
local lua_opts = lsp_zero.nvim_lua_ls() local lua_opts = lsp_zero.nvim_lua_ls()
require('lspconfig').lua_ls.setup(lua_opts) require("lspconfig").lua_ls.setup(lua_opts)
end, end,
} --ansiblels = function()
-- require("lspconfig").ansiblels.setup({
-- filetypes = "yaml",
-- })
--end,
},
}) })
end end,
} },
} }

View file

@ -6,9 +6,9 @@ return {
}, },
--config = function(lazy, opts) --config = function(lazy, opts)
config = function() config = function()
local telescope = require('telescope') local telescope = require("telescope")
telescope.load_extension('fzf') telescope.load_extension("fzf")
telescope.load_extension('file_browser') telescope.load_extension("file_browser")
telescope.setup({ telescope.setup({
defaults = { defaults = {
sorting_strategy = "ascending", sorting_strategy = "ascending",
@ -21,30 +21,29 @@ return {
width = 0.75, width = 0.75,
height = 0.75, height = 0.75,
preview_cutoff = 90, preview_cutoff = 90,
} },
} },
}, },
pickers = { pickers = {
find_files = { find_files = {
hidden = true hidden = true,
wrap_results = false, -- this is not about the preview
}, },
live_grep = { live_grep = {
additional_args = function() additional_args = function()
return { '--hidden', '--glob', '!**/.git/*' } return { "--hidden", "--glob", "!**/.git/*" }
end end,
}, },
grep_string = { grep_string = {
additional_args = function() additional_args = function()
return { '--hidden', '--glob', '!**/.git/*' } return { "--hidden", "--glob", "!**/.git/*" }
end end,
},
["lsp_references"] = { wrap_results = true },
["lsp_definitions"] = { wrap_results = true },
["diagnostics"] = { wrap_results = true },
["buffers"] = { sort_mru = true, ignore_current_buffer = false },
}, },
-- 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 end,
} }

View file

@ -10,13 +10,13 @@ return {
local treesitter = require("nvim-treesitter.configs") local treesitter = require("nvim-treesitter.configs")
treesitter.setup({ treesitter.setup({
highlight = { enable = true, }, highlight = { enable = true },
indent = { enable = true }, indent = { enable = true },
auto_install = false, auto_install = false,
-- language list: https://github.com/nvim-treesitter/nvim-treesitter#supported-languages -- language list: https://github.com/nvim-treesitter/nvim-treesitter#supported-languages
ensure_installed = { ensure_installed = {
"lua", "lua",
"comment", "comment", -- used for TODO/FIXME/NOTE etc
"vim", "vim",
"vimdoc", "vimdoc",
"bash", "bash",
@ -29,10 +29,18 @@ return {
"heex", "heex",
"yaml", "yaml",
"html", "html",
"javascript",
"css", "css",
"dockerfile", "dockerfile",
"query", "query",
"hcl", "hcl",
"bicep",
"csv",
"properties",
"ini",
"python",
"regex",
"json",
}, },
incremental_selection = { incremental_selection = {
enable = true, enable = true,
@ -44,5 +52,5 @@ return {
}, },
}, },
}) })
end end,
} }

View file

@ -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 = {},
}

View file

@ -9,7 +9,7 @@ vim.opt.number = true
vim.opt.relativenumber = true vim.opt.relativenumber = true
-- Separate sign colum (extra column for Git/LSP) -- Separate sign colum (extra column for Git/LSP)
vim.wo.signcolumn = 'yes' vim.wo.signcolumn = "yes"
vim.opt.tabstop = 4 vim.opt.tabstop = 4
vim.opt.softtabstop = 4 vim.opt.softtabstop = 4
@ -17,7 +17,7 @@ vim.opt.shiftwidth = 4
vim.opt.expandtab = true -- indent using spaces instead of <Tab> vim.opt.expandtab = true -- indent using spaces instead of <Tab>
-- highlight columns -- highlight columns
vim.opt.colorcolumn = '80,120' vim.opt.colorcolumn = "80,120"
-- Sync clipboard between OS and Neovim. -- Sync clipboard between OS and Neovim.
-- Remove this option if you want your OS clipboard to remain independent. -- 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.wrap = false
vim.opt.termguicolors = true 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 -- Themes: duskfox, tokyonight-night, tokyonight-storm, tokyonight-day, tokyonight-moon
vim.cmd.colorscheme 'tokyonight-storm' vim.cmd.colorscheme("tokyonight-storm")
-- Decrease update time -- Decrease update time
vim.opt.updatetime = 250 vim.opt.updatetime = 250
vim.opt.timeoutlen = 300 vim.opt.timeoutlen = 300
-- Set completeopt to have a better completion experience -- Set completeopt to have a better completion experience
vim.opt.completeopt = 'menuone,noselect' vim.opt.completeopt = "menuone,noselect"

View file

@ -18,13 +18,14 @@ vim.keymap.set(
":Telescope find_files hidden=true no_ignore=false <CR>", ":Telescope find_files hidden=true no_ignore=false <CR>",
{ noremap = true, desc = "File search" } { noremap = true, desc = "File search" }
) )
vim.keymap.set("n", "<leader>fg", ":Telescope live_grep<CR>", { noremap = true, desc = "Live grep through all files" }) --vim.keymap.set("n", "<leader>fg", ":Telescope live_grep<CR>", { noremap = true, desc = "Live grep through all files" })
vim.keymap.set( vim.keymap.set(
"n", "n",
"<leader><leader>", "<leader>fg",
":Telescope buffers preview=false<CR>", ":Telescope grep_string<CR>",
{ noremap = true, desc = "Show open buffers" } { noremap = true, desc = "Search text under cursor in cwd/grep search string" }
) )
vim.keymap.set("n", "<leader><leader>", ":Telescope buffers<CR>", { noremap = true, desc = "Show open buffers" })
vim.keymap.set("n", "<leader>gst", ":Telescope git_status<CR>", { noremap = true, desc = "Git status" }) vim.keymap.set("n", "<leader>gst", ":Telescope git_status<CR>", { noremap = true, desc = "Git status" })
vim.keymap.set( vim.keymap.set(
"n", "n",
@ -68,3 +69,5 @@ vim.keymap.set({ "n", "v" }, "<leader>o", function()
timeout_ms = 500, timeout_ms = 500,
}) })
end, { desc = "Format file or range (in visual mode)" }) end, { desc = "Format file or range (in visual mode)" })
vim.keymap.set("n", "<leader>z", ":ZenMode<CR>") -- toggle zen-mode.nvim