feat: use native nvim functionality
This commit is contained in:
306
init.lua
306
init.lua
@@ -1,197 +1,113 @@
|
|||||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
vim.opt.number = true
|
||||||
if not vim.loop.fs_stat(lazypath) then
|
vim.opt.relativenumber = true
|
||||||
vim.fn.system({
|
vim.opt.smartcase = true
|
||||||
"git",
|
vim.opt.ignorecase = true
|
||||||
"clone",
|
vim.opt.ts = 4
|
||||||
"--filter=blob:none",
|
vim.opt.sw = 0
|
||||||
"https://github.com/folke/lazy.nvim.git",
|
vim.opt.foldmethod = "indent"
|
||||||
"--branch=stable", -- latest stable release
|
vim.opt.foldlevel = 99
|
||||||
lazypath,
|
vim.opt.clipboard = "unnamedplus"
|
||||||
})
|
vim.opt.signcolumn = "yes"
|
||||||
end
|
vim.opt.termguicolors = true
|
||||||
vim.opt.rtp:prepend(lazypath)
|
|
||||||
|
|
||||||
|
vim.pack.add({
|
||||||
|
{ src = "https://github.com/stevearc/oil.nvim" },
|
||||||
|
{ src = "https://github.com/echasnovski/mini.pick" },
|
||||||
|
{ src = "https://github.com/echasnovski/mini.icons" },
|
||||||
|
{ src = "https://github.com/nvim-treesitter/nvim-treesitter" },
|
||||||
|
{ src = "https://github.com/neovim/nvim-lspconfig" },
|
||||||
|
{ src = "https://github.com/sainnhe/everforest" },
|
||||||
|
{ src = "https://github.com/nvim-lualine/lualine.nvim" },
|
||||||
|
|
||||||
require("lazy").setup({
|
|
||||||
spec = {
|
|
||||||
{
|
|
||||||
'windwp/nvim-ts-autotag',
|
|
||||||
lazy = false,
|
|
||||||
config = true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'terrortylor/nvim-comment',
|
|
||||||
lazy = false,
|
|
||||||
config = function()
|
|
||||||
require('nvim_comment').setup({
|
|
||||||
hook = function()
|
|
||||||
require('ts_context_commentstring.internal').update_commentstring()
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
dependencies = {
|
|
||||||
-- To customize commentstring for e.g. svelte files, as the commentstring is depending on cursor position
|
|
||||||
'JoosepAlviste/nvim-ts-context-commentstring'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
{
|
|
||||||
'williamboman/mason.nvim',
|
|
||||||
lazy = false,
|
|
||||||
config = true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'williamboman/mason-lspconfig.nvim',
|
|
||||||
lazy = false,
|
|
||||||
config = function()
|
|
||||||
local lsp_zero = require('lsp-zero')
|
|
||||||
|
|
||||||
lsp_zero.extend_lspconfig()
|
|
||||||
|
|
||||||
lsp_zero.on_attach(function(_, bufnr)
|
|
||||||
-- see :help lsp-zero-keybindings
|
|
||||||
-- to learn the available actions
|
|
||||||
lsp_zero.default_keymaps({ buffer = bufnr })
|
|
||||||
end)
|
|
||||||
|
|
||||||
require('mason-lspconfig').setup {
|
|
||||||
ensure_installed = { 'rust_analyzer', 'lua_ls' },
|
|
||||||
handlers = {
|
|
||||||
lsp_zero.default_setup
|
|
||||||
} }
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
|
|
||||||
{ 'VonHeikemen/lsp-zero.nvim' },
|
|
||||||
{ 'neovim/nvim-lspconfig' },
|
|
||||||
{ 'hrsh7th/cmp-nvim-lsp' },
|
|
||||||
{
|
|
||||||
'hrsh7th/nvim-cmp',
|
|
||||||
lazy = false,
|
|
||||||
config = function()
|
|
||||||
local cmp = require('cmp')
|
|
||||||
|
|
||||||
cmp.setup({
|
|
||||||
mapping = cmp.mapping.preset.insert({
|
|
||||||
-- add Ctrl+z to default keymap from lsp-zero as replacement to Ctrl+y on german keyboard layout
|
|
||||||
['<C-z>'] = cmp.mapping.confirm({ select = true }),
|
|
||||||
})
|
|
||||||
})
|
|
||||||
end
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'stevearc/conform.nvim',
|
|
||||||
lazy = false,
|
|
||||||
opts = {
|
|
||||||
notify_on_error = true,
|
|
||||||
formatters_by_ft = {
|
|
||||||
templ = { "templ" },
|
|
||||||
},
|
|
||||||
format_on_save = {
|
|
||||||
lsp_fallback = true,
|
|
||||||
timeout_ms = 1500,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
config = function(_, opts)
|
|
||||||
local plug = require('conform')
|
|
||||||
plug.setup(opts)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
-- status line
|
|
||||||
'nvim-lualine/lualine.nvim',
|
|
||||||
lazy = false,
|
|
||||||
config = true,
|
|
||||||
opts = {
|
|
||||||
options = {
|
|
||||||
theme = "everforest",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
dependencies = { 'nvim-tree/nvim-web-devicons' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'rcarriga/nvim-notify',
|
|
||||||
lazy = false,
|
|
||||||
config = function()
|
|
||||||
vim.notify = require('notify')
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'stevearc/oil.nvim',
|
|
||||||
lazy = false,
|
|
||||||
config = function()
|
|
||||||
require('oil').setup({
|
|
||||||
view_options = {
|
|
||||||
show_hidden = true,
|
|
||||||
sort = {
|
|
||||||
{ "type", "asc" },
|
|
||||||
{ "name", "asc" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
vim.keymap.set("n", "-", "<CMD>Oil<CR>", { desc = "Open parent directory" })
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'nvim-telescope/telescope.nvim',
|
|
||||||
opts = {
|
|
||||||
defaults = {
|
|
||||||
path_display = { "smart" },
|
|
||||||
file_ignore_patterns = { "node%_modules/.*" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
dependencies = { 'nvim-lua/plenary.nvim' },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"sainnhe/everforest",
|
|
||||||
priority = 1000, -- make sure to load this before all the other start plugins
|
|
||||||
config = function()
|
|
||||||
vim.cmd([[colorscheme everforest]])
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"nvim-treesitter/nvim-treesitter",
|
|
||||||
config = function()
|
|
||||||
require("nvim-treesitter.configs").setup {
|
|
||||||
auto_install = true,
|
|
||||||
highlight = {
|
|
||||||
enable = true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
vim.cmd([[TSUpdate]])
|
|
||||||
end
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
vim.g.mapleader = " "
|
require('lualine').setup({
|
||||||
|
options = {
|
||||||
|
theme = "everforest",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
-- line numbers
|
vim.cmd([[colorscheme everforest]])
|
||||||
vim.opt.rnu = true
|
require('mini.icons').setup()
|
||||||
vim.opt.nu = true
|
|
||||||
|
|
||||||
-- search
|
|
||||||
vim.opt.smartcase = true
|
|
||||||
vim.opt.ignorecase = true
|
|
||||||
|
|
||||||
-- tabstops
|
require('oil').setup({
|
||||||
vim.opt.ts = 4
|
view_options = {
|
||||||
vim.opt.sw = 0
|
show_hidden = true,
|
||||||
|
sort = {
|
||||||
|
{ "type", "asc" },
|
||||||
|
{ "name", "asc" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
-- folding
|
-- require("nvim-lspconfig").setup({ inlay_hints = { enabled = true } })
|
||||||
vim.opt.foldmethod = "indent"
|
|
||||||
vim.opt.foldlevel = 99
|
|
||||||
|
|
||||||
--clipboard
|
vim.api.nvim_create_autocmd('LspAttach', {
|
||||||
vim.opt.clipboard = "unnamedplus"
|
callback = function(ev)
|
||||||
|
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||||
|
if client:supports_method('textDocument/completion') then
|
||||||
|
vim.lsp.completion.enable(true, client.id, ev.buf, { autotrigger = true })
|
||||||
|
end
|
||||||
|
|
||||||
-- other
|
if client:supports_method("textDocument/inlayHint") or client.server_capabilities.inlayHintProvider then
|
||||||
vim.opt.signcolumn = "yes"
|
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
vim.cmd("set completeopt+=menuone,noselect,popup")
|
||||||
|
|
||||||
-- colortheme
|
vim.lsp.config('gopls', {
|
||||||
vim.opt.termguicolors = true
|
settings = {
|
||||||
|
['gopls'] = {
|
||||||
|
hints = {
|
||||||
|
assignVariableTypes = true,
|
||||||
|
parameterNames = true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
vim.lsp.enable({ "lua_ls", "gopls" })
|
||||||
|
|
||||||
|
require "mini.pick".setup()
|
||||||
|
require "nvim-treesitter.configs".setup({
|
||||||
|
auto_install = true,
|
||||||
|
highlight = { enable = true }
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
-- 'windwp/nvim-ts-autotag',
|
||||||
|
-- 'terrortylor/nvim-comment',
|
||||||
|
-- config = function()
|
||||||
|
-- require('nvim_comment').setup({
|
||||||
|
-- hook = function()
|
||||||
|
-- require('ts_context_commentstring.internal').update_commentstring()
|
||||||
|
-- end,
|
||||||
|
-- })
|
||||||
|
-- end,
|
||||||
|
-- dependencies = {
|
||||||
|
-- -- To customize commentstring for e.g. svelte files, as the commentstring is depending on cursor position
|
||||||
|
-- 'JoosepAlviste/nvim-ts-context-commentstring'
|
||||||
|
-- }
|
||||||
|
-- {
|
||||||
|
-- 'stevearc/conform.nvim',
|
||||||
|
-- opts = {
|
||||||
|
-- notify_on_error = true,
|
||||||
|
-- formatters_by_ft = {
|
||||||
|
-- templ = { "templ" },
|
||||||
|
-- },
|
||||||
|
-- format_on_save = {
|
||||||
|
-- lsp_fallback = true,
|
||||||
|
-- timeout_ms = 1500,
|
||||||
|
-- },
|
||||||
|
-- },
|
||||||
|
-- config = function(_, opts)
|
||||||
|
-- local plug = require('conform')
|
||||||
|
-- plug.setup(opts)
|
||||||
|
-- end,
|
||||||
|
-- },
|
||||||
|
-- {
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd('TextYankPost', {
|
vim.api.nvim_create_autocmd('TextYankPost', {
|
||||||
desc = 'Hightlight selection on yank',
|
desc = 'Hightlight selection on yank',
|
||||||
@@ -201,8 +117,23 @@ vim.api.nvim_create_autocmd('TextYankPost', {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||||
|
desc = 'Atuformat code on save',
|
||||||
|
pattern = '*',
|
||||||
|
callback = function()
|
||||||
|
vim.lsp.buf.format()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
vim.filetype.add({ extension = { templ = "templ" } })
|
vim.filetype.add({ extension = { templ = "templ" } })
|
||||||
|
|
||||||
|
vim.g.mapleader = " "
|
||||||
|
|
||||||
|
vim.keymap.set('i', '<C-n>', vim.lsp.completion.get, {})
|
||||||
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, {})
|
||||||
|
vim.keymap.set('n', 'gr', vim.lsp.buf.references, {})
|
||||||
|
vim.keymap.set('n', '<F2>', vim.lsp.buf.rename, {})
|
||||||
|
vim.keymap.set('n', '<F4>', vim.lsp.buf.code_action, {})
|
||||||
|
|
||||||
vim.keymap.set('n', '<leader>q', ':q<CR>', {})
|
vim.keymap.set('n', '<leader>q', ':q<CR>', {})
|
||||||
vim.keymap.set('n', '<leader>w', ':w<CR>', {})
|
vim.keymap.set('n', '<leader>w', ':w<CR>', {})
|
||||||
@@ -210,8 +141,9 @@ vim.keymap.set('n', '<leader>c', ':noh<CR>', {})
|
|||||||
vim.keymap.set('n', '<leader>en', vim.diagnostic.goto_next, {})
|
vim.keymap.set('n', '<leader>en', vim.diagnostic.goto_next, {})
|
||||||
vim.keymap.set('n', '<leader>ep', vim.diagnostic.goto_prev, {})
|
vim.keymap.set('n', '<leader>ep', vim.diagnostic.goto_prev, {})
|
||||||
|
|
||||||
local telescope = require('telescope.builtin')
|
vim.keymap.set('n', '<leader>ff', ":Pick files<CR>", {})
|
||||||
vim.keymap.set('n', '<leader>ff', telescope.find_files, {})
|
-- vim.keymap.set('n', '<leader>fg', telescope.live_grep, {})
|
||||||
vim.keymap.set('n', '<leader>fg', telescope.live_grep, {})
|
-- vim.keymap.set('n', '<leader>fb', telescope.buffers, {})
|
||||||
vim.keymap.set('n', '<leader>fb', telescope.buffers, {})
|
vim.keymap.set('n', '<leader>fh', ":Pick help<CR>", {})
|
||||||
vim.keymap.set('n', '<leader>fh', telescope.help_tags, {})
|
|
||||||
|
vim.keymap.set("n", "-", "<CMD>Oil<CR>", { desc = "Open parent directory" })
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
{
|
|
||||||
"LuaSnip": { "branch": "master", "commit": "66b5c2707e624dcd2cd3605676c64a2efe47e9d1" },
|
|
||||||
"cmp-nvim-lsp": { "branch": "main", "commit": "a8912b88ce488f411177fc8aed358b04dc246d7b" },
|
|
||||||
"conform.nvim": { "branch": "master", "commit": "973f3cb73887d510321653044791d7937c7ec0fa" },
|
|
||||||
"everforest": { "branch": "master", "commit": "f40c2e6c8784c99c57c79edc94cd180e76450222" },
|
|
||||||
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
|
|
||||||
"lsp-zero.nvim": { "branch": "v4.x", "commit": "d388e2b71834c826e61a3eba48caec53d7602510" },
|
|
||||||
"lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" },
|
|
||||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "bb3a17efc797c34c054463174e5522442576ebd8" },
|
|
||||||
"mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" },
|
|
||||||
"nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" },
|
|
||||||
"nvim-comment": { "branch": "main", "commit": "e9ac16ab056695cad6461173693069ec070d2b23" },
|
|
||||||
"nvim-lspconfig": { "branch": "master", "commit": "7a88e3024a616e153b8760d64b3541e3a166c27f" },
|
|
||||||
"nvim-notify": { "branch": "master", "commit": "a22f5d7ac511c2df2fd3290a9f04c48d5a822e2e" },
|
|
||||||
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
|
|
||||||
"nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" },
|
|
||||||
"nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" },
|
|
||||||
"nvim-web-devicons": { "branch": "master", "commit": "0422a19d9aa3aad2c7e5cca167e5407b13407a9d" },
|
|
||||||
"oil.nvim": { "branch": "master", "commit": "bbad9a76b2617ce1221d49619e4e4b659b3c61fc" },
|
|
||||||
"plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },
|
|
||||||
"telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user