Created
April 1, 2025 08:38
-
-
Save manzanit0/00eb96a168b87198000fa5888bc1b6b3 to your computer and use it in GitHub Desktop.
Neovim config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---@diagnostic disable: undefined-global | |
if vim.g.vscode then | |
return | |
end | |
-- encoding | |
vim.o.encoding = "utf-8" | |
vim.o.fileencoding = "utf-8" | |
-- timeouts | |
vim.o.ttyfast = true -- we have a fast terminal | |
vim.o.ttimeout = true --time out for key codes | |
vim.o.ttimeoutlen = 100 -- wait up to 100ms after Esc for special key | |
vim.o.lazyredraw = true | |
-- safety net | |
vim.o.undofile = true -- store undos on disk | |
vim.o.updatetime = 300 -- flush swap files to disk on a regular basis | |
-- search and replace | |
vim.o.showmatch = true -- sm: flashes matching brackets or parentheses | |
vim.o.hlsearch = true -- Highlights the areas that you search for. | |
vim.o.incsearch = true --Searches incrementally as you type. | |
vim.o.ignorecase = true -- ignore case when searching | |
vim.o.smartcase = true -- smarter search case | |
vim.o.wildignorecase = true -- ignore case in file completion | |
vim.o.wildignore = "" -- remove default ignores | |
vim.o.wildignore = vim.o.wildignore .. "*.o,*.obj,*.so,*.a,*.dylib,*.pyc,*.hi" -- ignore compiled files | |
vim.o.wildignore = vim.o.wildignore .. "*.zip,*.gz,*.xz,*.tar,*.rar" -- ignore compressed files | |
vim.o.wildignore = vim.o.wildignore .. "*/.git/*,*/.hg/*,*/.svn/*" -- ignore SCM files | |
vim.o.wildignore = vim.o.wildignore .. "*.png,*.jpg,*.jpeg,*.gif" -- ignore image files | |
vim.o.wildignore = vim.o.wildignore .. "*.pdf,*.dmg" -- ignore binary files | |
vim.o.wildignore = vim.o.wildignore .. ".*.sw*,*~" -- ignore editor files | |
vim.o.wildignore = vim.o.wildignore .. ".DS_Store" -- ignore OS files | |
-- folding | |
vim.o.foldmethod = "expr" | |
vim.o.foldexpr = "nvim_treesitter#foldexpr()" | |
vim.g.nosmartindent = true | |
vim.o.autoindent = true | |
vim.o.cursorline = true | |
-- TODO: need to look how to set this... apparently it's not vim.o.nofoldenable. | |
vim.cmd [[ set nofoldenable ]] | |
-- spacing | |
vim.o.backspace = "indent,eol,start" | |
vim.o.laststatus = 2 -- Shows the current status of the file. | |
vim.o.expandtab = true -- Replaces a <TAB> with spaces | |
vim.o.shiftwidth = 2 -- The amount to block indent when using < and > | |
vim.o.shiftround = true -- Shift to the next round tab stop | |
vim.o.tabstop = 2 -- 2 space tab | |
vim.o.softtabstop = 2 -- Causes backspace to delete 2 spaces = converted <TAB> | |
vim.o.smarttab = true -- Uses shiftwidth instead of tabstop at start of lines | |
-- numbers in the side | |
vim.o.nu = true | |
vim.o.number = true | |
vim.o.numberwidth = 5 | |
-- copy&paste works with the system too. | |
-- @see https://vim.fandom.com/wiki/Accessing_the_system_clipboard | |
vim.o.clipboard = "unnamedplus" -- In case of Linux | |
-- set clipboard=unnamed " This would be for OSx. | |
-- when scrolling off-screen do so 3 lines at a time, not 1 | |
vim.o.scrolloff = 3 | |
-- open new split panes to right and bottom, which feels more natural | |
vim.o.splitbelow = true | |
vim.o.splitright = true | |
-- vim.o.diffopt = vim.o.diffopt .. "vertical" | |
vim.g.mapleader = ";" | |
vim.g.maplocalleader = ";" | |
-- tpope/vim-unimpaired uses '[' and ']', however, they're not too comfortable on my | |
-- layout. '<' and '>' are much better. | |
vim.cmd [[ | |
nmap < [ | |
nmap > ] | |
omap < [ | |
omap > ] | |
xmap < [ | |
xmap > ] | |
]] | |
-- In case you use :terminal, bring back ESC. | |
vim.cmd [[ tnoremap <Esc> <C-\><C-n> ]] | |
vim.cmd [[ | |
function! ToggleQuickFix() | |
if getqflist({'winid':0}).winid | |
cclose | |
else | |
copen | |
endif | |
endfunction | |
command! -nargs=0 -bar ToggleQuickFix call ToggleQuickFix() | |
nnoremap <silent> cq :ToggleQuickFix<CR> | |
]] | |
vim.cmd([[ | |
autocmd BufNewFile,BufRead *.Jenkinsfile set filetype=groovy | |
]]) | |
vim.cmd [[ autocmd BufRead Tiltfile set filetype=tiltfile ]] | |
vim.cmd [[ au FileType tiltfile set syntax=starlark ]] | |
vim.api.nvim_create_autocmd('TextYankPost', { | |
desc = 'Highlight when yanking (copying) text', | |
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), | |
callback = function() | |
vim.highlight.on_yank() | |
end, | |
}) | |
-- mappings | |
for _, mapping in ipairs({ | |
-- save current buffer | |
{ "n", "<cr>", "<cmd>w<cr>" }, | |
-- better `j` and `k` | |
{ "n", "j", "gj" }, | |
{ "v", "j", "gj" }, | |
{ "n", "k", "gk" }, | |
{ "v", "k", "gk" }, | |
-- copy from the cursor to the end of line using Y (matches D behavior) | |
{ "n", "Y", "y$" }, | |
-- keep the cursor in place while joining lines | |
{ "n", "J", "mZJ`Z" }, | |
-- reselect visual block after indent | |
{ "v", "<", "<gv" }, | |
{ "v", ">", ">gv" }, | |
-- clean screen and reload file | |
{ "n", "<c-l>", "<cmd>nohl<cr>:redraw<cr>:checktime<cr><c-l>gjgk" }, | |
-- emulate permanent global marks | |
{ "n", "<leader>nc", "<cmd>edit ~/.config/nvim/init.lua<cr>" }, | |
-- absolute path (/something/src/foo.txt) | |
{ "n", "<leader>cF", ":let @+=expand(\"%:p\")<CR>" }, | |
-- relative path | |
{ "n", "<leader>cf", ":let @+=expand(\"%\")<CR>" }, | |
-- keep the cursor in place while joining lines | |
{ "n", "J", "mZJ`Z" }, | |
{ "n", "<leader>qq", ":qa!<CR>" }, | |
}) do | |
vim.keymap.set(mapping[1], mapping[2], mapping[3], { noremap = true, silent = true }) | |
end | |
-- Sets how neovim will display certain whitespace characters in the editor. | |
-- See `:help 'list'` | |
-- and `:help 'listchars'` | |
-- vim.opt.list = true | |
-- vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } | |
-- " Highlights with a small shadow all code surpassing 80 characters. | |
-- highlight OverLength ctermbg=red ctermfg=white guibg=#592929 | |
-- match OverLength /\%81v.\+/ | |
-- enable ayu? | |
-- vim.cmd([[ | |
-- let ayucolor="mirage" | |
-- colorscheme ayu | |
-- ]]) | |
vim.o.termguicolors = true | |
vim.loader.enable() | |
-- [[ Install `lazy.nvim` plugin manager ]] | |
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info | |
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' | |
if not vim.loop.fs_stat(lazypath) then | |
local lazyrepo = 'https://github.com/folke/lazy.nvim.git' | |
vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } | |
end ---@diagnostic disable-next-line: undefined-field | |
vim.opt.rtp:prepend(lazypath) | |
require('lazy').setup({ | |
-- Themes | |
-- { | |
-- 'projekt0n/github-nvim-theme', | |
-- lazy = false, -- make sure we load this during startup if it is your main colorscheme | |
-- priority = 1000, -- make sure to load this before all the other start plugins | |
-- config = function() | |
-- require('github-theme').setup({}) | |
-- vim.cmd('colorscheme github_dark') | |
-- end, | |
-- }, | |
"tpope/vim-surround", | |
"tpope/vim-unimpaired", | |
"tpope/vim-rhubarb", | |
"yasuhiroki/github-actions-yaml.vim", | |
"onsails/lspkind.nvim", | |
"stevearc/dressing.nvim", | |
'rhysd/conflict-marker.vim', | |
'kosayoda/nvim-lightbulb', | |
{ 'projekt0n/github-nvim-theme' }, | |
{ "romainl/Apprentice", }, | |
{ "ayu-theme/ayu-vim", }, | |
{ | |
'kaiuri/nvim-juliana', | |
opts = {}, | |
config = true, | |
}, | |
-- Behaviour | |
{ | |
"vim-test/vim-test", | |
config = function() | |
vim.keymap.set("n", "<leader>te", "<cmd>TestNearest<CR>", { noremap = true, silent = true }) | |
vim.keymap.set("n", "<leader>Te", "<cmd>TestFile<CR>", { noremap = true, silent = true }) | |
end | |
}, | |
{ | |
'numToStr/Comment.nvim', | |
opts = {} | |
}, | |
{ | |
"s1n7ax/nvim-terminal", | |
lazy = true, -- not using much these days | |
config = function() | |
vim.o.hidden = true -- this is needed to be set to reuse terminal between toggles | |
require('nvim-terminal').setup({ | |
toggle_keymap = '<C-_>', | |
increase_height_keymap = '<leader>t=', | |
decrease_height_keymap = '<leader>t-', | |
window_height_change_amount = 25, | |
}) | |
end | |
}, | |
{ | |
"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 | |
}, | |
config = function() | |
-- Unless you are still migrating, remove the deprecated commands from v1.x | |
vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]]) | |
vim.keymap.set("n", "<leader>o", "<cmd>Neotree focus<cr>", { noremap = true, silent = true }) | |
vim.keymap.set("n", "<leader>e", "<cmd>Neotree toggle<cr>", { noremap = true, silent = true }) | |
vim.keymap.set("n", "-", "<cmd>Neotree reveal<cr>", { noremap = true, silent = true }) | |
vim.keymap.set("n", "\\", "<cmd>Neotree toggle current reveal_force_cwd<cr>", | |
{ noremap = true, silent = true }) | |
require("neo-tree").setup({ | |
close_if_last_window = true, | |
window = { | |
position = "right", | |
}, | |
filesystem = { | |
hijack_netrw_behavior = "open_default", | |
filtered_items = { | |
visible = true, | |
hide_dotfiles = false, | |
hide_gitignored = false, | |
hide_by_name = { | |
".git", | |
}, | |
}, | |
window = { | |
mappings = { | |
["h"] = "toggle_hidden", | |
} | |
}, | |
} | |
}) | |
end | |
}, | |
{ | |
"nvim-telescope/telescope.nvim", | |
tag = '0.1.8', | |
lazy = false, | |
dependencies = { | |
'nvim-lua/plenary.nvim', | |
-- don't use this, it's more annoying than anything else. | |
-- 'jonarrien/telescope-cmdline.nvim', | |
}, | |
config = function() | |
local builtin = require('telescope.builtin') | |
vim.keymap.set("n", "<leader>ff", builtin.find_files, {}) | |
vim.keymap.set("n", "<leader>fg", builtin.live_grep, {}) | |
vim.keymap.set("n", "<leader>fb", builtin.buffers, {}) | |
vim.keymap.set("n", "<leader>fh", builtin.help_tags, {}) | |
local trouble = require("trouble.sources.telescope") | |
local telescope = require("telescope") | |
telescope.setup { | |
defaults = { | |
mappings = { | |
i = { ["<c-t>"] = trouble.open }, | |
n = { ["<c-t>"] = trouble.open }, | |
}, | |
}, | |
pickers = { | |
find_files = { | |
-- `hidden = true` will still show the inside of `.git/` as it's not `.gitignore`d. | |
find_command = { "rg", "--files", "--hidden", "--glob", "!**/.git/*" }, | |
}, | |
}, | |
extensions = { | |
fzf = { | |
fuzzy = true, -- false will only do exact matching | |
override_generic_sorter = true, -- override the generic sorter | |
override_file_sorter = true, -- override the file sorter | |
case_mode = "smart_case", -- or "ignore_case" or "respect_case" | |
-- the default case_mode is "smart_case" | |
} | |
} | |
} | |
require('telescope').load_extension('fzf') | |
end | |
}, | |
{ | |
'nvim-telescope/telescope-fzf-native.nvim', | |
build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release', | |
}, | |
{ | |
"folke/trouble.nvim", | |
opts = {}, | |
cmd = "Trouble", | |
keys = { | |
{ | |
"<leader>xx", | |
"<cmd>Trouble diagnostics toggle<cr>", | |
desc = "Diagnostics (Trouble)", | |
}, | |
{ | |
"<leader>xX", | |
"<cmd>Trouble diagnostics toggle filter.buf=0<cr>", | |
desc = "Buffer Diagnostics (Trouble)", | |
}, | |
{ | |
"<leader>cs", | |
"<cmd>Trouble symbols toggle focus=false<cr>", | |
desc = "Symbols (Trouble)", | |
}, | |
{ | |
"<leader>cl", | |
"<cmd>Trouble lsp toggle focus=false win.position=right<cr>", | |
desc = "LSP Definitions / references / ... (Trouble)", | |
}, | |
{ | |
"<leader>xL", | |
"<cmd>Trouble loclist toggle<cr>", | |
desc = "Location List (Trouble)", | |
}, | |
{ | |
"<leader>xQ", | |
"<cmd>Trouble qflist toggle<cr>", | |
desc = "Quickfix List (Trouble)", | |
}, | |
}, | |
}, | |
{ | |
"simrat39/symbols-outline.nvim", | |
opts = {}, | |
config = function() | |
vim.keymap.set("n", "<leader>m", "<cmd>SymbolsOutline<cr>", { noremap = true, silent = true }) | |
end | |
}, | |
{ | |
"tpope/vim-fugitive", | |
config = function() | |
vim.keymap.set("n", "<Leader>gs", "<cmd>Git<cr>", { noremap = true, silent = true }) | |
vim.keymap.set("n", "<leader>gpu", "<cmd>Git push<cr>", { desc = "Git push" }) | |
end | |
}, | |
-- { | |
-- "lewis6991/gitsigns.nvim", | |
-- tag = "v1.0.1", | |
-- config = function() | |
-- require('gitsigns').setup() | |
-- end | |
-- }, | |
{ | |
'ruifm/gitlinker.nvim', | |
dependencies = { 'nvim-lua/plenary.nvim' }, | |
config = function() | |
local gitlinker = require("gitlinker") | |
gitlinker.setup({ mappings = nil }) | |
vim.keymap.set("n", "<leader>gb", "", { | |
silent = true, | |
desc = "browse repo in browser", | |
callback = function() | |
gitlinker.get_repo_url({ | |
action_callback = gitlinker.actions.open_in_browser | |
}) | |
end | |
}) | |
vim.keymap.set({ "n", "v" }, "<leader>gl", "", { | |
silent = true, | |
desc = "get git permlink", | |
callback = function() | |
local mode = string.lower(vim.fn.mode()) | |
gitlinker.get_buf_range_url(mode) | |
end, | |
}) | |
end | |
}, | |
{ | |
"nvim-treesitter/nvim-treesitter", | |
build = ":TSUpdate", | |
opts = { | |
ensure_installed = { | |
'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc', | |
"proto", | |
"lua", | |
"bash", | |
"yaml", "json", | |
"go", "gomod", "gowork", | |
"dockerfile", "hcl", "terraform", | |
"elixir", | |
"starlark", | |
"javascript", "typescript" | |
}, | |
-- Autoinstall languages that are not installed | |
-- auto_install = true, | |
highlight = { enable = true, }, | |
indent = { enable = true }, | |
}, | |
config = function(_, opts) | |
-- Prefer git instead of curl in order to improve connectivity in some environments | |
require('nvim-treesitter.install').prefer_git = true | |
---@diagnostic disable-next-line: missing-fields | |
require('nvim-treesitter.configs').setup(opts) | |
vim.treesitter.language.register("starlark", "tiltfile") | |
end, | |
}, | |
{ | |
"neovim/nvim-lspconfig", -- neovim lsp config plugin | |
dependencies = { | |
{ 'williamboman/mason.nvim', config = true }, -- NOTE: Must be loaded before dependants | |
"williamboman/mason-lspconfig.nvim", | |
{ "hrsh7th/nvim-cmp", }, | |
-- event = { "InsertEnter", "CmdlineEnter" } | |
"hrsh7th/vim-vsnip", | |
"hrsh7th/cmp-buffer", | |
"hrsh7th/cmp-cmdline", | |
"hrsh7th/cmp-nvim-lsp", | |
"hrsh7th/cmp-nvim-lsp-signature-help", | |
"hrsh7th/cmp-path", | |
"hrsh7th/cmp-vsnip", | |
{ 'folke/neodev.nvim', opts = {} }, | |
{ 'j-hui/fidget.nvim', opts = {} }, | |
}, | |
config = function() | |
require("mason").setup() | |
require("mason-lspconfig").setup({ automatic_installation = true }) | |
local cmp = require("cmp") | |
local lspkind = require('lspkind') | |
cmp.setup({ | |
completion = { completeopt = "menu,menuone,noinsert" }, | |
experimental = { ghost_text = true }, | |
preselect = cmp.PreselectMode.None, | |
window = { documentation = cmp.config.window.bordered() }, | |
snippet = { | |
expand = function(args) | |
vim.fn["vsnip#anonymous"](args.body) | |
end, | |
formatting = { | |
format = lspkind.cmp_format({ | |
mode = 'symbol', -- show only symbol annotations | |
maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) | |
ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first) | |
-- The function below will be called before any actual modifications from lspkind | |
-- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30)) | |
before = function(_, vim_item) | |
return vim_item | |
end | |
}) | |
} | |
}, | |
mapping = { | |
-- ['<C-m>'] = function() | |
-- if cmp.visible() then | |
-- cmp.close() | |
-- else | |
-- cmp.complete {} | |
-- end | |
-- end, | |
["<CR>"] = cmp.config.disable, | |
["<tab>"] = cmp.mapping(cmp.mapping.confirm({ select = true }), { "i" }), | |
-- ["<C-enter>"] = cmp.mapping(cmp.mapping.confirm({ select = true }), { "i" }), | |
["<C-n>"] = cmp.mapping(cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), { "i" }), | |
["<C-p>"] = cmp.mapping(cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), { "i" }), | |
["<C-j>"] = cmp.mapping(cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), { "i" }), | |
["<C-k>"] = cmp.mapping(cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), { "i" }), | |
["<C-d>"] = cmp.mapping(cmp.mapping.scroll_docs(4), { "i" }), | |
["<C-u>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), { "i" }), | |
}, | |
sources = cmp.config.sources({ | |
{ name = "nvim_lsp" }, | |
{ name = "nvim_lsp_signature_help" }, | |
}, { | |
{ name = "path" }, | |
}, { | |
{ name = "buffer" }, | |
}), | |
}) | |
local capabilities = require("cmp_nvim_lsp").default_capabilities() | |
local flags = { debounce_text_changes = 150 } | |
local handlers = { | |
["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" }), | |
} | |
-- diagnostics | |
vim.keymap.set('n', '<F8>', vim.diagnostic.goto_next, { noremap = true, silent = true }) | |
-- FIXME: the Shift+F8 isn't quite working. Too bad I don't use it much. | |
vim.keymap.set('n', '<S-F8>', vim.diagnostic.goto_prev, { noremap = true, silent = true }) | |
-- Note: By leveraging the quickfix list instead of location, we get | |
-- project wide diagnostics instead of bufferwise. | |
vim.keymap.set('n', '<space>q', vim.diagnostic.setqflist, { noremap = true, silent = true }) | |
vim.api.nvim_create_autocmd('LspAttach', { | |
group = vim.api.nvim_create_augroup('lsp-attach', { clear = true }), | |
callback = function(event) | |
local map = function(keys, func, desc) | |
vim.keymap.set('n', keys, func, | |
{ buffer = event.buf, desc = 'LSP: ' .. desc }) | |
end | |
-- code actions | |
map("ff", vim.lsp.buf.format, '[F]ormat') | |
-- vim.keymap.set('n', '<C-i>', vim.lsp.buf.code_action, opts) -- handled by aznhe21/actions-preview.nvim | |
map('<F2>', vim.lsp.buf.rename, 'Rename') | |
-- code navigation | |
map('gd', vim.lsp.buf.definition, '[G]o [D]efinition') | |
map('gD', vim.lsp.buf.declaration, '[G]o [D]eclaration') | |
map("K", vim.lsp.buf.hover, 'Hover Documentation') | |
-- references code navigation (quickfix list) | |
map("gr", vim.lsp.buf.references, '[G]o [R]eferences') | |
map("<leader>gr", require('telescope.builtin').lsp_references, | |
'[G]o [R]eferences') | |
map("gI", vim.lsp.buf.implementation, '[G]o [I]mplementation') | |
map("<leader>gI", require('telescope.builtin').lsp_implementations, | |
'[G]o [I]mplementation') | |
-- references code navigation (Telescope) | |
map('<leader>ds', require('telescope.builtin').lsp_document_symbols, | |
'[D]ocument [S]ymbols') | |
map('<leader>D', require('telescope.builtin').lsp_type_definitions, | |
'[D]efinition') | |
map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ctions') | |
vim.api.nvim_buf_set_option(event.buf, "omnifunc", "v:lua.vim.lsp.omnifunc") | |
end | |
}) | |
local nvim_lsp = require('lspconfig') | |
for _, lsp in pairs({ | |
-- "golangci_lint_ls", | |
"ts_ls", | |
"ocamlls", | |
"terraformls", | |
"clojure_lsp", | |
"dartls", | |
"bashls", | |
"vale_ls", | |
"lua_ls", | |
"sqls", | |
}) do | |
nvim_lsp[lsp].setup({ | |
capabilities = capabilities, | |
flags = flags, | |
handlers = handlers, | |
}) | |
end | |
require 'lspconfig'.tilt_ls.setup {} | |
require 'lspconfig'.pylsp.setup { | |
settings = { | |
pylsp = { | |
plugins = { | |
pycodestyle = { | |
maxLineLength = 100 | |
} | |
} | |
} | |
} | |
} | |
-- Configure `ruff-lsp`. | |
-- See: https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md#ruff_lsp | |
-- For the default config, along with instructions on how to customize the settings | |
require('lspconfig').ruff.setup { | |
init_options = { | |
settings = { | |
-- Any extra CLI arguments for `ruff` go here. | |
args = {}, | |
} | |
} | |
} | |
-- To avoid issues where both tsserver and denols are attached to your | |
-- current buffer make sure to set some unique root_dir for both | |
-- tsserver and denols. You may also need to set single_file_support | |
-- to false for tsserver to prevent it from running in single file mode | |
nvim_lsp.denols.setup { | |
on_attach = on_attach, | |
flags = flags, | |
handlers = handlers, | |
root_dir = nvim_lsp.util.root_pattern("deno.json", "deno.jsonc"), | |
} | |
nvim_lsp.ts_ls.setup { | |
on_attach = on_attach, | |
flags = flags, | |
handlers = handlers, | |
root_dir = nvim_lsp.util.root_pattern("package.json"), | |
single_file_support = false | |
} | |
nvim_lsp.gopls.setup({ | |
capabilities = capabilities, | |
flags = flags, | |
handlers = handlers, | |
settings = { | |
gopls = { | |
buildFlags = { "-tags=db_tests,integration_tests" }, | |
gofumpt = true, | |
}, | |
}, | |
}) | |
nvim_lsp.yamlls.setup { | |
settings = { | |
yaml = { | |
schemas = { | |
["https://json.schemastore.org/github-workflow.json"] = "/.github/workflows/*", | |
["https://json.schemastore.org/github-action.json"] = "/action.yaml" | |
}, | |
}, | |
} | |
} | |
nvim_lsp.helm_ls.setup { | |
settings = { | |
['helm-ls'] = { | |
valuesFiles = { | |
mainValuesFile = "values.yaml", | |
lintOverlayValuesFile = "values.lint.yaml", | |
additionalValuesFilesGlobPattern = "values*.yaml" | |
}, | |
yamlls = { | |
path = "yaml-language-server", | |
enabled = false, | |
diagnosticsLimit = 50, | |
showDiagnosticsDirectly = false, | |
config = { | |
schemas = { | |
kubernetes = "templates/**", | |
}, | |
completion = true, | |
hover = true, | |
-- any other config from https://github.com/redhat-developer/yaml-language-server#language-server-settings | |
} | |
} | |
} | |
} | |
} | |
-- Need to manually install? | |
-- curl -fLO https://github.com/elixir-lsp/elixir-ls/releases/latest/download/elixir-ls.zip | |
-- unzip elixir-ls.zip -d ~/.elixir-ls | |
-- chmod +x ~/.elixir-ls/language_server.sh | |
nvim_lsp.elixirls.setup({ | |
cmd = { "/Users/manzanit0/.elixir-ls/language_server.sh" }, | |
capabilities = capabilities, | |
flags = flags, | |
handlers = handlers, | |
}) | |
-- git clone [email protected]:GroovyLanguageServer/groovy-language-server.git ~/groovy-ls | |
-- cd ~/groovy-ls | |
-- ./gradlew build | |
nvim_lsp.groovyls.setup({ | |
cmd = { "java", "-jar", "/Users/manzanit0/groovy-ls/build/libs/groovy-ls-all.jar" }, | |
capabilities = capabilities, | |
flags = flags, | |
handlers = handlers, | |
}) | |
vim.api.nvim_create_autocmd("CursorHold", { | |
buffer = bufnr, | |
callback = function() | |
local float_opts = { | |
focusable = false, | |
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" }, | |
border = "rounded", | |
source = "always", -- show source in diagnostic popup window | |
prefix = " ", | |
} | |
if not vim.b.diagnostics_pos then | |
vim.b.diagnostics_pos = { nil, nil } | |
end | |
local cursor_pos = vim.api.nvim_win_get_cursor(0) | |
if (cursor_pos[1] ~= vim.b.diagnostics_pos[1] or cursor_pos[2] ~= vim.b.diagnostics_pos[2]) | |
and #vim.diagnostic.get() > 0 | |
then | |
vim.diagnostic.open_float(nil, float_opts) | |
end | |
vim.b.diagnostics_pos = cursor_pos | |
end, | |
}) | |
end, | |
}, | |
{ | |
"aznhe21/actions-preview.nvim", | |
config = function() | |
vim.keymap.set({ "v", "n" }, "gf", require("actions-preview").code_actions) | |
end, | |
}, | |
-- { | |
-- "towolf/vim-helm", | |
-- ft = "helm", | |
-- }, | |
-- { | |
-- "iamcco/markdown-preview.nvim", | |
-- run = function() vim.fn["mkdp#util#install"]() end, | |
-- }, | |
{ | |
'akinsho/flutter-tools.nvim', | |
opts = {}, | |
dependencies = { | |
'nvim-lua/plenary.nvim', | |
'stevearc/dressing.nvim', -- optional for vim.ui.select | |
}, | |
}, | |
{ | |
"natecraddock/workspaces.nvim", | |
config = function() | |
require("workspaces").setup() | |
require("telescope").load_extension('workspaces') | |
vim.keymap.set("n", "<leader>dw", "<cmd>Telescope workspaces<CR>", | |
{ noremap = true, silent = true }) | |
end, | |
}, | |
{ | |
"folke/todo-comments.nvim", | |
dependencies = { "nvim-lua/plenary.nvim" }, | |
}, | |
{ | |
"dlants/magenta.nvim", | |
lazy = false, -- you could also bind to <leader>mt | |
build = "npm install --frozen-lockfile", | |
opts = {}, | |
}, | |
}) | |
local function org_imports() | |
local clients = vim.lsp.get_clients() | |
for _, client in pairs(clients) do | |
local params = vim.lsp.util.make_range_params(nil, client.offset_encoding) | |
params.context = { only = { "source.organizeImports" } } | |
local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, 5000) | |
for _, res in pairs(result or {}) do | |
for _, r in pairs(res.result or {}) do | |
if r.edit then | |
vim.lsp.util.apply_workspace_edit(r.edit, client.offset_encoding) | |
else | |
vim.lsp.buf.execute_command(r.command) | |
end | |
end | |
end | |
end | |
-- after organising imports, format. | |
vim.lsp.buf.format() | |
end | |
vim.api.nvim_create_autocmd("BufWritePre", { | |
pattern = { "*.lua", "*.ex", "*.exs" }, | |
callback = vim.lsp.buf.format, | |
}) | |
vim.api.nvim_create_autocmd("BufWritePre", { | |
pattern = { "*.go" }, | |
callback = org_imports, | |
}) | |
vim.cmd([[colorscheme github_dark]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment