commit 27df93fb3804efec4b9d2641e1f08276ce433225
parent b5a7923328961879b9ded558ac9530e71988af85
Author: Tomas Nemec <nemi@skaut.cz>
Date: Wed, 29 Sep 2021 10:35:21 +0200
feat: dart `:DartOorganizeImports`
Diffstat:
4 files changed, 152 insertions(+), 34 deletions(-)
diff --git a/ftplugin/dart.lua b/ftplugin/dart.lua
@@ -3,11 +3,13 @@ local kb = require('tms.c.keybind')
vim.g.dart_style_guide = 2
vim.g.dart_html_in_string = true
-vim.cmd [[command! DartAnalyzer lua require('tms.ft.dart.analyze').qf2103()]]
-vim.cmd [[command! DartDebug lua require('tms.ft.dart.debug').func()]]
-vim.cmd [[command! DartPrint lua require('tms.ft.dart.debug').print()]]
+vim.cmd [[command! -buffer DartAnalyzer lua require('tms.ft.dart.analyze').qf2103()]]
+vim.cmd [[command! -buffer DartDebug lua require('tms.ft.dart.debug').func()]]
+vim.cmd [[command! -buffer DartPrint lua require('tms.ft.dart.debug').print()]]
+vim.cmd [[command! -buffer DartOrganizeImports lua require('tms.ft.dart.lsp').organize_imports()]]
kb.bnnoremap(0, '<leader>pp', [[<cmd>DartPrint<cr>]])
+kb.bnnoremap(0, '<leader>po', [[<cmd>DartOrganizeImports<cr>]])
if vim.fn.getline(1):match('^#!.*dcli') then
vim.cmd [[comp dcli]]
diff --git a/ftplugin/go.lua b/ftplugin/go.lua
@@ -1,2 +1,2 @@
vim.cmd [[comp go]]
-vim.cmd [[command! -nargs=? Godoc lua require('tms.ft.go.doc').godoc(vim.fn.expand('<args>'), vim.fn.expand('<cword>'))]]
+vim.cmd [[command! -buffer -nargs=? Godoc lua require('tms.ft.go.doc').godoc(vim.fn.expand('<args>'), vim.fn.expand('<cword>'))]]
diff --git a/lua/tms/ft/dart/lsp.lua b/lua/tms/ft/dart/lsp.lua
@@ -0,0 +1,17 @@
+local lsp = vim.lsp
+local api = vim.api
+
+local M = {}
+
+M.organize_imports = function()
+ local cur_buf = api.nvim_get_current_buf()
+ local cur_buf_name = api.nvim_buf_get_name(cur_buf)
+ local params = {
+ command = 'edit.organizeImports',
+ arguments = {cur_buf_name},
+ title = '',
+ }
+ lsp.buf_request_sync(cur_buf, 'workspace/executeCommand', params, 1500)
+end
+
+return M
diff --git a/lua/tms/plugins.lua b/lua/tms/plugins.lua
@@ -8,7 +8,10 @@ local function init()
local use = packer.use
packer.reset()
- use {'wbthomason/packer.nvim', opt = true}
+ use {
+ 'wbthomason/packer.nvim',
+ opt = true,
+ }
use 'lewis6991/impatient.nvim'
-- spell
@@ -41,7 +44,9 @@ local function init()
use {
'b3nj5m1n/kommentary',
config = function()
- require('kommentary.config').configure_language('default', {prefer_single_line_comments = true})
+ require('kommentary.config').configure_language('default', {
+ prefer_single_line_comments = true,
+ })
end,
}
use { -- undo tree
@@ -57,7 +62,9 @@ local function init()
'camspiers/animate.vim',
config = function()
vim.cmd('let g:animate#duration = 100.0')
- local silent = {silent = true}
+ local silent = {
+ silent = true,
+ }
local kb = require('tms.c.keybind')
kb.nmap('<c-up>', ':call animate#window_delta_height(10)<cr>', silent)
kb.nmap('<c-down>', ':call animate#window_delta_height(-10)<cr>', silent)
@@ -117,7 +124,10 @@ local function init()
use 'chaoren/vim-wordmotion' -- word counts with _,.,-,...
use {
'hoob3rt/lualine.nvim',
- requires = {'kyazdani42/nvim-web-devicons', opt = true},
+ requires = {
+ 'kyazdani42/nvim-web-devicons',
+ opt = true,
+ },
config = function() require('tms.p.status').setup() end,
}
use {'joeytwiddle/sexy_scroller.vim'} -- smooth scrolling
@@ -188,11 +198,21 @@ local function init()
requires = {'nvim-lua/plenary.nvim'},
config = function()
require('neorg').setup {
- load = {['core.defaults'] = {}},
+ load = {
+ ['core.defaults'] = {},
+ },
['core.norg.concealer'] = {},
- ['core.norg.completion'] = {config = {engine = 'nvim-compe'}},
+ ['core.norg.completion'] = {
+ config = {
+ engine = 'nvim-compe',
+ },
+ },
['core.norg.dirman'] = { -- Manage your directories with Neorg
- config = {workspaces = {my_workspace = '~/.neorg'}},
+ config = {
+ workspaces = {
+ my_workspace = '~/.neorg',
+ },
+ },
},
}
end,
@@ -208,7 +228,10 @@ local function init()
vim.g.qf_auto_resize = 0
end,
}
- use {'kevinhwang91/nvim-bqf', config = function() require('tms.p.bqf').setup() end}
+ use {
+ 'kevinhwang91/nvim-bqf',
+ config = function() require('tms.p.bqf').setup() end,
+ }
-- distraction
use 'junegunn/limelight.vim'
@@ -250,7 +273,11 @@ local function init()
'TimUntersberger/neogit',
requires = {'nvim-lua/plenary.nvim', 'sindrets/diffview.nvim'},
config = function()
- require('neogit').setup {integrations = {diffview = true}}
+ require('neogit').setup {
+ integrations = {
+ diffview = true,
+ },
+ }
local kb = require('tms.c.keybind')
kb.nnoremap('<leader>gn', '<cmd>Neogit kind=split<cr>')
end,
@@ -273,7 +300,10 @@ local function init()
} -- git info for current line
-- colorscheme
- use {'ishan9299/nvim-solarized-lua', config = function() end}
+ use {
+ 'ishan9299/nvim-solarized-lua',
+ config = function() end,
+ }
use {
'morhetz/gruvbox',
config = function()
@@ -286,9 +316,23 @@ local function init()
after = {'gruvbox', 'nvim-solarized-lua'},
config = function() require('tms.colors').setup() end,
}
+ use {
+ 'ThePrimeagen/git-worktree.nvim',
+ after = {'telescope.nvim'},
+ config = function()
+ require('git-worktree').setup()
+ local kb = require('tms.c.keybind')
+ require('telescope').load_extension('git_worktree')
+ kb.nnoremap('<space>wo', require('telescope').extensions.git_worktree.git_worktrees)
+ kb.nnoremap('<space>wi', require('telescope').extensions.git_worktree.create_git_worktree)
+ end,
+ }
-- http
- use {disable = true, 'nicwest/vim-http'}
+ use {
+ disable = true,
+ 'nicwest/vim-http',
+ }
use {
'NTBBloodbath/rest.nvim',
requires = {'nvim-lua/plenary.nvim'},
@@ -316,7 +360,10 @@ local function init()
}
-- tasks
- use {'amirrezaask/actions.nvim', config = function() require('tms.p.actions').setup() end}
+ use {
+ 'amirrezaask/actions.nvim',
+ config = function() require('tms.p.actions').setup() end,
+ }
use {
'skywind3000/asyncrun.vim',
config = function()
@@ -336,15 +383,30 @@ local function init()
}
use 'tikhomirov/vim-glsl'
use 'mattn/emmet-vim'
- use {'windwp/nvim-ts-autotag', config = function() require('nvim-ts-autotag').setup {} end} -- html tag autoclose/rename
- use {'vim-php/vim-composer', config = function() vim.g.composer_cmd = 'composer' end}
+ use {
+ 'windwp/nvim-ts-autotag',
+ config = function() require('nvim-ts-autotag').setup {} end,
+ } -- html tag autoclose/rename
+ use {
+ 'vim-php/vim-composer',
+ config = function() vim.g.composer_cmd = 'composer' end,
+ }
use 'fpob/nette.vim'
use 'baskerville/vim-sxhkdrc'
- use {'dart-lang/dart-vim-plugin', ft = {'dart'}}
- use {'akinsho/dependency-assist.nvim', config = function() require'dependency_assist'.setup() end}
+ use {
+ 'dart-lang/dart-vim-plugin',
+ ft = {'dart'},
+ }
+ use {
+ 'akinsho/dependency-assist.nvim',
+ config = function() require'dependency_assist'.setup() end,
+ }
-- snippets
- use {'norcalli/snippets.nvim', config = function() require('tms.p.snippets').setup() end}
+ use {
+ 'norcalli/snippets.nvim',
+ config = function() require('tms.p.snippets').setup() end,
+ }
-- completion
use {
@@ -354,20 +416,42 @@ local function init()
require('tms.p.compe').setup()
local kb = require('tms.c.keybind')
-- kb.inoremap('<c-space>', 'compe#complete()', {silent = true, expr = true})
- kb.inoremap('<cr>', 'compe#confirm("<cr>")', {silent = true, expr = true})
- kb.inoremap('<c-e>', 'compe#close("<c-e>")', {silent = true, expr = true})
- kb.imap('<Tab>', 'v:lua.tab_complete()', {expr = true})
- kb.smap('<Tab>', 'v:lua.tab_complete()', {expr = true})
- kb.imap('<S-Tab>', 'v:lua.s_tab_complete()', {expr = true})
- kb.smap('<S-Tab>', 'v:lua.s_tab_complete()', {expr = true})
+ kb.inoremap('<cr>', 'compe#confirm("<cr>")', {
+ silent = true,
+ expr = true,
+ })
+ kb.inoremap('<c-e>', 'compe#close("<c-e>")', {
+ silent = true,
+ expr = true,
+ })
+ kb.imap('<Tab>', 'v:lua.tab_complete()', {
+ expr = true,
+ })
+ kb.smap('<Tab>', 'v:lua.tab_complete()', {
+ expr = true,
+ })
+ kb.imap('<S-Tab>', 'v:lua.s_tab_complete()', {
+ expr = true,
+ })
+ kb.smap('<S-Tab>', 'v:lua.s_tab_complete()', {
+ expr = true,
+ })
end,
}
- use {disable = false, 'tamago324/compe-zsh', requires = {'hrsh7th/nvim-compe', 'nvim-lua/plenary.nvim'}}
+ use {
+ disable = false,
+ 'tamago324/compe-zsh',
+ requires = {'hrsh7th/nvim-compe', 'nvim-lua/plenary.nvim'},
+ }
use {
disable = true,
'ms-jpq/coq_nvim',
branch = 'coq',
- config = function() vim.g.coq_settings = {['display.pum.source_context'] = {'', ''}} end,
+ config = function()
+ vim.g.coq_settings = {
+ ['display.pum.source_context'] = {'', ''},
+ }
+ end,
}
-- ui
@@ -376,7 +460,10 @@ local function init()
-- lsp
use 'neovim/nvim-lspconfig'
- use {disable = true, 'RRethy/vim-illuminate'}
+ use {
+ disable = true,
+ 'RRethy/vim-illuminate',
+ }
use 'ray-x/lsp_signature.nvim'
use 'alexaandru/nvim-lspupdate'
use {
@@ -384,7 +471,10 @@ local function init()
requires = 'kyazdani42/nvim-web-devicons',
config = function() require('trouble').setup {} end,
}
- use {'folke/lua-dev.nvim', config = function() end}
+ use {
+ 'folke/lua-dev.nvim',
+ config = function() end,
+ }
use {
'jose-elias-alvarez/null-ls.nvim',
config = function()
@@ -397,7 +487,10 @@ local function init()
-- use 'mfussenegger/nvim-jdtls'
-- dap
- use {'mfussenegger/nvim-dap', config = function() require('tms.p.dap').setup() end}
+ use {
+ 'mfussenegger/nvim-dap',
+ config = function() require('tms.p.dap').setup() end,
+ }
use {
'rcarriga/nvim-dap-ui',
requires = 'mfussenegger/nvim-dap',
@@ -413,7 +506,10 @@ local function init()
end,
requires = {'jbyuki/one-small-step-for-vimkind', 'mfussenegger/nvim-dap'},
}
- use {'theHamsta/nvim-dap-virtual-text', requires = {'mfussenegger/nvim-dap'}}
+ use {
+ 'theHamsta/nvim-dap-virtual-text',
+ requires = {'mfussenegger/nvim-dap'},
+ }
-- treesitter
use {
@@ -478,7 +574,10 @@ local function init()
kb.nnoremap('<space>P', telescope.plugins)
end,
}
- use {'nvim-telescope/telescope-packer.nvim', after = {'telescope.nvim'}}
+ use {
+ 'nvim-telescope/telescope-packer.nvim',
+ after = {'telescope.nvim'},
+ }
use {
'nvim-telescope/telescope-fzy-native.nvim',
after = {'telescope.nvim'},