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>
- 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>

View file

@ -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" }
}

View file

@ -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({
['<C-Space>'] = cmp.mapping.complete(),
['<C-u>'] = cmp.mapping.scroll_docs(-4),
['<C-d>'] = cmp.mapping.scroll_docs(4),
['<C-l>'] = cmp.mapping.confirm({select = true}), -- accept LSP autocompletion
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
['<C-f>'] = cmp_action.luasnip_jump_forward(),
['<C-b>'] = cmp_action.luasnip_jump_backward(),
})
})
end
},
cmp.setup({
formatting = lsp_zero.cmp_format(),
mapping = cmp.mapping.preset.insert({
["<C-Space>"] = cmp.mapping.complete(),
["<C-u>"] = cmp.mapping.scroll_docs(-4),
["<C-d>"] = cmp.mapping.scroll_docs(4),
["<C-l>"] = cmp.mapping.confirm({ select = true }), -- accept LSP autocompletion
["<C-p>"] = cmp.mapping.select_prev_item(cmp_select),
["<C-n>"] = cmp.mapping.select_next_item(cmp_select),
["<C-f>"] = cmp_action.luasnip_jump_forward(),
["<C-b>"] = 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,
},
}

View file

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

View file

@ -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 = "<C-space>",
node_incremental = "<C-space>",
scope_incremental = false,
node_decremental = "<bs>",
},
},
})
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 = "<C-space>",
node_incremental = "<C-space>",
scope_incremental = false,
node_decremental = "<bs>",
},
},
})
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
-- 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 <Tab>
-- 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"

View file

@ -18,13 +18,14 @@ vim.keymap.set(
":Telescope find_files hidden=true no_ignore=false <CR>",
{ 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(
"n",
"<leader><leader>",
":Telescope buffers preview=false<CR>",
{ noremap = true, desc = "Show open buffers" }
"<leader>fg",
":Telescope grep_string<CR>",
{ 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",
@ -68,3 +69,5 @@ vim.keymap.set({ "n", "v" }, "<leader>o", function()
timeout_ms = 500,
})
end, { desc = "Format file or range (in visual mode)" })
vim.keymap.set("n", "<leader>z", ":ZenMode<CR>") -- toggle zen-mode.nvim