Reformatted code after changing indent width to 2, TODO highlighting

- set all indent widths from 4 to 2
- added plugin to highlight TODO markers, can also be searched
  <leader>ft
This commit is contained in:
2024-09-19 21:48:06 +02:00
parent 73cb9eeca1
commit 1e98df6cc3
4 changed files with 309 additions and 289 deletions

View File

@@ -6,16 +6,17 @@ vim.keymap.set('n', '<leader>fg', fzf.live_grep, { desc = "Grep" })
vim.keymap.set('n', '<leader>fG', fzf.grep_cword, { desc = "Grep word under cursor" }) vim.keymap.set('n', '<leader>fG', fzf.grep_cword, { desc = "Grep word under cursor" })
vim.keymap.set('n', '<leader>fc', fzf.commands, { desc = "Commands" }) vim.keymap.set('n', '<leader>fc', fzf.commands, { desc = "Commands" })
vim.keymap.set('n', '<leader>fm', fzf.manpages, { desc = "Manpages" }) vim.keymap.set('n', '<leader>fm', fzf.manpages, { desc = "Manpages" })
vim.keymap.set('n', '<leader>b', fzf.buffers, { desc = "Buffers" }) vim.keymap.set('n', '<leader>b', fzf.buffers, { desc = "Buffers" })
vim.keymap.set('n', '<leader>ft', ":TodoFzfLua<CR>", { desc = "Todos" })
-- use fzf buffer lines as default search -- use fzf buffer lines as default search
vim.keymap.set('n', '/', fzf.blines, { desc = "Search buffer" }) vim.keymap.set('n', '/', fzf.blines, { desc = "Search buffer" })
vim.keymap.set('n', 'z=', fzf.spell_suggest, { desc = "Spelling suggestions" }) vim.keymap.set('n', 'z=', fzf.spell_suggest, { desc = "Spelling suggestions" })
-- open file manager and git -- open file manager and git
vim.keymap.set('n', '<leader>g', ":Neogit<CR>", { desc = "Git Manager" }) vim.keymap.set('n', '<leader>g', ":Neogit<CR>", { desc = "Neogit" })
vim.keymap.set('n', '<leader>T', ":Neotree<CR>", { desc = "File Manager" }) vim.keymap.set('n', '<leader>T', ":Neotree reveal<CR>", { desc = "File Manager" })
-- --
-- configure workspaces -- configure workspaces

View File

@@ -1,25 +1,26 @@
require('mason').setup({ require('mason').setup({
ui = { ui = {
icons = { icons = {
package_installed = "", package_installed = "",
package_pending = "", package_pending = "",
package_uninstalled = "" package_uninstalled = ""
}
} }
}
}) })
require('mason-lspconfig').setup({ require('mason-lspconfig').setup({
-- A list of servers to automatically install if they're not already installed -- A list of servers to automatically install if they're not already installed
ensure_installed = { ensure_installed = {
'pylsp', 'pylsp',
'lua_ls', 'lua_ls',
'rust_analyzer', 'rust_analyzer',
'yamlls', 'yamlls',
'tsserver', 'ts_ls',
'gopls', 'gopls',
'pylsp', 'pylsp',
-- 'volar', 'clangd',
}, -- 'volar',
},
}) })
-- Customized on_attach function -- Customized on_attach function
@@ -33,38 +34,38 @@ vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
-- Use an on_attach function to only map the following keys -- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer -- after the language server attaches to the current buffer
local on_attach = function(client, bufnr) local on_attach = function(client, bufnr)
-- Enable completion triggered by <c-x><c-o> -- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
-- See `:help vim.lsp.*` for documentation on any of the below functions -- See `:help vim.lsp.*` for documentation on any of the below functions
local bufopts = { noremap = true, silent = true, buffer = bufnr } local bufopts = { noremap = true, silent = true, buffer = bufnr }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts) vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts) vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts) vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wl', function() vim.keymap.set('n', '<space>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders())) print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, bufopts) end, bufopts)
-- vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts) -- vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts) vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
-- vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts) -- vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
vim.keymap.set("n", "<space>f", function() vim.keymap.set("n", "<space>f", function()
vim.lsp.buf.format({ async = true }) vim.lsp.buf.format({ async = true })
end, bufopts) end, bufopts)
-- 2024-09-09 - some ccflow commands -- 2024-09-09 - some ccflow commands
local fzf = require('fzf-lua') local fzf = require('fzf-lua')
vim.keymap.set('n', '<space>d', fzf.diagnostics_document , { desc = "Doc diagnostics" }) vim.keymap.set('n', '<space>d', fzf.diagnostics_document, { desc = "Doc diagnostics" })
vim.keymap.set('n', '<space>D', fzf.diagnostics_workspace, { desc = "Workspace diagnostics" }) vim.keymap.set('n', '<space>D', fzf.diagnostics_workspace, { desc = "Workspace diagnostics" })
vim.keymap.set('n', '<space>s', fzf.lsp_document_symbols, { desc = "Doc symbols" }) vim.keymap.set('n', '<space>s', fzf.lsp_document_symbols, { desc = "Doc symbols" })
vim.keymap.set('n', '<space>c', fzf.lsp_code_actions, { desc = "Code Actions" }) vim.keymap.set('n', '<space>c', fzf.lsp_code_actions, { desc = "Code Actions" })
-- vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) -- vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
vim.keymap.set('n', '<C-[>', fzf.lsp_references, { desc = "Find References" }) vim.keymap.set('n', '<C-[>', fzf.lsp_references, { desc = "Find References" })
vim.keymap.set('n', '<C-]>', fzf.lsp_definitions, { desc = "Find References" }) vim.keymap.set('n', '<C-]>', fzf.lsp_definitions, { desc = "Find References" })
end end
-- Set different settings for different languages' LSP -- Set different settings for different languages' LSP
@@ -76,34 +77,34 @@ local lspconfig = require('lspconfig')
-- from :h mason-lspconfig-automatic-server-setup -- from :h mason-lspconfig-automatic-server-setup
require('mason-lspconfig').setup_handlers({ require('mason-lspconfig').setup_handlers({
-- The first entry (without a key) will be the default handler -- The first entry (without a key) will be the default handler
-- and will be called for each installed server that doesn't have -- and will be called for each installed server that doesn't have
-- a dedicated handler. -- a dedicated handler.
function(server_name) -- default handler (optional) function(server_name) -- default handler (optional)
if server_name == 'tsserver' then if server_name == 'ts_ls' then
-- taken from https://github.com/vuejs/language-tools -- taken from https://github.com/vuejs/language-tools
-- If you are using mason.nvim, you can get the ts_plugin_path like this -- If you are using mason.nvim, you can get the ts_plugin_path like this
local mason_registry = require('mason-registry') local mason_registry = require('mason-registry')
local vue_language_server_path = mason_registry.get_package('vue-language-server'):get_install_path() .. local vue_language_server_path = mason_registry.get_package('vue-language-server'):get_install_path() ..
'/node_modules/@vue/language-server' '/node_modules/@vue/language-server'
lspconfig[server_name].setup { lspconfig[server_name].setup {
on_attach = on_attach, on_attach = on_attach,
init_options = { init_options = {
plugins = { plugins = {
{ {
name = '@vue/typescript-plugin', name = '@vue/typescript-plugin',
location = vue_language_server_path, location = vue_language_server_path,
languages = { 'vue' }, languages = { 'vue' },
}, },
}, },
}, },
filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' }, filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' },
} }
else else
lspconfig[server_name].setup { lspconfig[server_name].setup {
on_attach = on_attach on_attach = on_attach
} }
end
end end
end
}) })

View File

@@ -4,9 +4,9 @@ vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
vim.opt.mouse = 'a' -- allow the mouse to be used in Nvim vim.opt.mouse = 'a' -- allow the mouse to be used in Nvim
-- Tab -- Tab
vim.opt.tabstop = 4 -- number of visual spaces per TAB vim.opt.tabstop = 2 -- number of visual spaces per TAB
vim.opt.softtabstop = 4 -- number of spacesin tab when editing vim.opt.softtabstop = 2 -- number of spacesin tab when editing
vim.opt.shiftwidth = 4 -- insert 4 spaces on a tab vim.opt.shiftwidth = 2 -- insert 4 spaces on a tab
vim.opt.expandtab = true -- tabs are spaces, mainly because of python vim.opt.expandtab = true -- tabs are spaces, mainly because of python
-- UI config -- UI config

View File

@@ -1,228 +1,246 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then if not (vim.uv or vim.loop).fs_stat(lazypath) then
vim.fn.system({ vim.fn.system({
"git", "git",
"clone", "clone",
"--filter=blob:none", "--filter=blob:none",
"https://github.com/folke/lazy.nvim.git", "https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release "--branch=stable", -- latest stable release
lazypath, lazypath,
}) })
end end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
require("lazy").setup({ require("lazy").setup({
-- Vscode-like pictograms -- Vscode-like pictograms
{ {
"onsails/lspkind.nvim", "onsails/lspkind.nvim",
event = { "VimEnter" }, event = { "VimEnter" },
},
-- Auto-completion engine
{
"hrsh7th/nvim-cmp",
dependencies = {
"lspkind.nvim",
"hrsh7th/cmp-nvim-lsp", -- lsp auto-completion
"hrsh7th/cmp-buffer", -- buffer auto-completion
"hrsh7th/cmp-path", -- path auto-completion
"hrsh7th/cmp-cmdline", -- cmdline auto-completion
}, },
config = function()
require("config.nvim-cmp")
end,
},
-- Auto-completion engine -- Code snippet engine
{ {
"hrsh7th/nvim-cmp", "L3MON4D3/LuaSnip",
dependencies = { version = "v2.*",
"lspkind.nvim", },
"hrsh7th/cmp-nvim-lsp", -- lsp auto-completion
"hrsh7th/cmp-buffer", -- buffer auto-completion -- LSP manager
"hrsh7th/cmp-path", -- path auto-completion "williamboman/mason.nvim",
"hrsh7th/cmp-cmdline", -- cmdline auto-completion "williamboman/mason-lspconfig.nvim",
}, "neovim/nvim-lspconfig",
config = function()
require("config.nvim-cmp") -- neogit setup
end, {
"NeogitOrg/neogit",
dependencies = {
"nvim-lua/plenary.nvim", -- required
"sindrets/diffview.nvim", -- optional - Diff integration
-- Only one of these is needed, not both.
-- "nvim-telescope/telescope.nvim", -- optional
"ibhagwan/fzf-lua", -- optional
}, },
config = true
},
-- Code snippet engine -- org-mode
{ {
"L3MON4D3/LuaSnip", 'nvim-orgmode/orgmode',
version = "v2.*", event = 'VeryLazy',
}, ft = { 'org' },
config = function()
-- Setup orgmode
require('orgmode').setup({
org_agenda_files = '~/orgfiles/**/*',
org_default_notes_file = '~/orgfiles/refile.org',
})
-- LSP manager -- NOTE: If you are using nvim-treesitter with ~ensure_installed = "all"~ option
"williamboman/mason.nvim", -- add ~org~ to ignore_install
"williamboman/mason-lspconfig.nvim", -- require('nvim-treesitter.configs').setup({
"neovim/nvim-lspconfig", -- ensure_installed = 'all',
-- ignore_install = { 'org' },
-- })
end,
},
-- neogit setup -- fzf-lua
{ {
"NeogitOrg/neogit", "ibhagwan/fzf-lua",
dependencies = { -- optional for icon support
"nvim-lua/plenary.nvim", -- required dependencies = { "nvim-tree/nvim-web-devicons" },
"sindrets/diffview.nvim", -- optional - Diff integration config = function()
-- calling `setup` is optional for customization
require("fzf-lua").setup({})
end
},
-- Only one of these is needed, not both. -- whichkey
-- "nvim-telescope/telescope.nvim", -- optional {
"ibhagwan/fzf-lua", -- optional "folke/which-key.nvim",
}, event = "VeryLazy",
config = true opts = {
}, -- your configuration comes here
-- or leave it empty to use the default settings
-- org-mode -- refer to the configuration section below
{ preset = 'helix',
'nvim-orgmode/orgmode', expand = 4,
event = 'VeryLazy', keys = {
ft = { 'org' }, scroll_down = "<c-d>", -- binding to scroll down inside the popup
config = function() scroll_up = "<c-u>", -- binding to scroll up inside the popup
-- Setup orgmode },
require('orgmode').setup({ plugins = {
org_agenda_files = '~/orgfiles/**/*', presets = {
org_default_notes_file = '~/orgfiles/refile.org', motions = true,
}) g = true,
-- NOTE: If you are using nvim-treesitter with ~ensure_installed = "all"~ option
-- add ~org~ to ignore_install
-- require('nvim-treesitter.configs').setup({
-- ensure_installed = 'all',
-- ignore_install = { 'org' },
-- })
end,
},
-- fzf-lua
{
"ibhagwan/fzf-lua",
-- optional for icon support
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
-- calling `setup` is optional for customization
require("fzf-lua").setup({})
end
},
-- whichkey
{
"folke/which-key.nvim",
event = "VeryLazy",
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
preset = 'helix',
expand = 4,
keys = {
scroll_down = "<c-d>", -- binding to scroll down inside the popup
scroll_up = "<c-u>", -- binding to scroll up inside the popup
},
},
keys = {
{
"<leader>?",
function()
require("which-key").show({ global = false })
end,
desc = "Buffer Local Keymaps (which-key)",
},
},
},
-- treesitter
{
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
config = function()
local configs = require("nvim-treesitter.configs")
configs.setup({
ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "elixir", "heex", "javascript", "html", "diff", "go", "rust", "python" },
sync_install = false,
highlight = { enable = true },
indent = { enable = true },
})
end
},
-- lualine statusline plugin
{
'nvim-lualine/lualine.nvim',
dependencies = { 'nvim-tree/nvim-web-devicons' },
config = function()
require("lualine").setup {
options = {
icons_enabled = false,
theme = 'papercolor_light',
component_separators = {},
section_separators = {},
disabled_filetypes = {
statusline = {},
winbar = {},
},
ignore_focus = {},
always_divide_middle = true,
globalstatus = false,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
}
},
sections = {
lualine_a = { 'filename' },
lualine_b = { 'branch', 'diff', 'diagnostics' },
lualine_c = {},
lualine_x = { 'encoding', 'fileformat', 'filetype' },
lualine_y = { 'filesize' },
lualine_z = { 'progress', 'location' }
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { 'filename' },
lualine_x = { 'location' },
lualine_y = {},
lualine_z = {}
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {}
}
end
},
-- neo-tree file management
{
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
"MunifTanjim/nui.nvim",
-- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information
} }
},
}, },
keys = {
-- workspaces, lightweight "projects" {
{ "<leader>?",
"natecraddock/workspaces.nvim", function()
config = function() require("which-key").show({ global = false })
require("workspaces").setup { end,
-- sort the list of workspaces by name after loading from the workspaces path. desc = "Buffer Local Keymaps (which-key)",
sort = true, },
-- sort by recent use rather than by name. requires sort to be true
mru_sort = false,
-- option to automatically activate workspace when opening neovim in a workspace directory
auto_open = true,
-- option to automatically activate workspace when changing directory not via this plugin
auto_dir = true,
hooks = {
open = "FzfLua files"
}
}
end
}, },
dependencies = { "echasnovski/mini.icons" },
},
-- rpn calculator -- treesitter
-- also added as source to cmp {
{ "nvim-treesitter/nvim-treesitter",
"PhilRunninger/cmp-rpncalc", build = ":TSUpdate",
}, config = function()
local configs = require("nvim-treesitter.configs")
-- comfortable table editing configs.setup({
{ 'dhruvasagar/vim-table-mode' }, ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "elixir", "heex", "javascript", "html", "diff", "go", "rust", "python" },
sync_install = false,
highlight = { enable = true },
indent = { enable = true },
})
end
},
-- lualine statusline plugin
{
'nvim-lualine/lualine.nvim',
dependencies = { 'nvim-tree/nvim-web-devicons' },
config = function()
require("lualine").setup {
options = {
icons_enabled = false,
theme = 'papercolor_light',
component_separators = {},
section_separators = {},
disabled_filetypes = {
statusline = {},
winbar = {},
},
ignore_focus = {},
always_divide_middle = true,
globalstatus = false,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
}
},
sections = {
lualine_a = { 'filename' },
lualine_b = { 'branch', 'diff', 'diagnostics' },
lualine_c = {},
lualine_x = { 'encoding', 'fileformat', 'filetype' },
lualine_y = { 'filesize' },
lualine_z = { 'progress', 'location' }
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { 'filename' },
lualine_x = { 'location' },
lualine_y = {},
lualine_z = {}
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {}
}
end
},
-- neo-tree file management
{
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
"MunifTanjim/nui.nvim",
-- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information
}
},
-- workspaces, lightweight "projects"
{
"natecraddock/workspaces.nvim",
config = function()
require("workspaces").setup {
-- sort the list of workspaces by name after loading from the workspaces path.
sort = true,
-- sort by recent use rather than by name. requires sort to be true
mru_sort = false,
-- option to automatically activate workspace when opening neovim in a workspace directory
auto_open = true,
-- option to automatically activate workspace when changing directory not via this plugin
auto_dir = true,
hooks = {
open = "FzfLua files"
}
}
end
},
-- rpn calculator
-- also added as source to cmp
{
"PhilRunninger/cmp-rpncalc",
},
-- comfortable table editing
{ 'dhruvasagar/vim-table-mode' },
-- TODO, WARN, HACK, PERF, NOTE, TEST and others highlighting and searching
{
"folke/todo-comments.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
},
}) })